git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 04/10] t3511-cherry-pick-x.sh: use the $( ... ) construct for command substitution

From
Elia Pinto <gitter.spiros@gmail.com>
Date
Dec 22, 2015, 15:27 UTC
Message-ID
<1450798073-22811-5-git-send-email-gitter.spiros@gmail.com>
In-Reply-To
<1450798073-22811-1-git-send-email-gitter.spiros@gmail.com>

The Git CodingGuidelines prefer the $(...) construct for command substitution instead of using the backquotes `...`.

The backquoted form is the traditional method for command substitution, and is supported by POSIX. However, all but the simplest uses become complicated quickly. In particular, embedded command substitutions and/or the use of double quotes require careful escaping with the backslash character.

The patch was generated by:
for _f in $(find . -name "*.sh")
do
	perl -i -pe 'BEGIN{undef $/;} s/`(.+?)`/\$(\1)/smg'  "${_f}"
done
and then carefully proof-read.
Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 t/t3511-cherry-pick-x.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/t/t3511-cherry-pick-x.sh b/t/t3511-cherry-pick-x.sh
index b7dff09..9cce5ae 100755
--- a/t/t3511-cherry-pick-x.sh
+++ b/t/t3511-cherry-pick-x.sh
@@ -77,7 +77,7 @@ test_expect_success setup '
 
 test_expect_success 'cherry-pick -x inserts blank line after one line subject' '
 	pristine_detach initial &&
-	sha1=`git rev-parse mesg-one-line^0` &&
+	sha1=$(git rev-parse mesg-one-line^0) &&
 	git cherry-pick -x mesg-one-line &&
 	cat <<-EOF >expect &&
 		$mesg_one_line
@@ -114,7 +114,7 @@ test_expect_success 'cherry-pick -s inserts blank line after non-conforming foot
 
 test_expect_success 'cherry-pick -x inserts blank line when conforming footer not found' '
 	pristine_detach initial &&
-	sha1=`git rev-parse mesg-no-footer^0` &&
+	sha1=$(git rev-parse mesg-no-footer^0) &&
 	git cherry-pick -x mesg-no-footer &&
 	cat <<-EOF >expect &&
 		$mesg_no_footer
@@ -139,7 +139,7 @@ test_expect_success 'cherry-pick -s inserts blank line when conforming footer no
 
 test_expect_success 'cherry-pick -x -s inserts blank line when conforming footer not found' '
 	pristine_detach initial &&
-	sha1=`git rev-parse mesg-no-footer^0` &&
+	sha1=$(git rev-parse mesg-no-footer^0) &&
 	git cherry-pick -x -s mesg-no-footer &&
 	cat <<-EOF >expect &&
 		$mesg_no_footer
@@ -164,7 +164,7 @@ test_expect_success 'cherry-pick -s adds sob when last sob doesnt match committe
 
 test_expect_success 'cherry-pick -x -s adds sob when last sob doesnt match committer' '
 	pristine_detach initial &&
-	sha1=`git rev-parse mesg-with-footer^0` &&
+	sha1=$(git rev-parse mesg-with-footer^0) &&
 	git cherry-pick -x -s mesg-with-footer &&
 	cat <<-EOF >expect &&
 		$mesg_with_footer
@@ -187,7 +187,7 @@ test_expect_success 'cherry-pick -s refrains from adding duplicate trailing sob'
 
 test_expect_success 'cherry-pick -x -s adds sob even when trailing sob exists for committer' '
 	pristine_detach initial &&
-	sha1=`git rev-parse mesg-with-footer-sob^0` &&
+	sha1=$(git rev-parse mesg-with-footer-sob^0) &&
 	git cherry-pick -x -s mesg-with-footer-sob &&
 	cat <<-EOF >expect &&
 		$mesg_with_footer_sob
@@ -200,7 +200,7 @@ test_expect_success 'cherry-pick -x -s adds sob even when trailing sob exists fo
 
 test_expect_success 'cherry-pick -x treats "(cherry picked from..." line as part of footer' '
 	pristine_detach initial &&
-	sha1=`git rev-parse mesg-with-cherry-footer^0` &&
+	sha1=$(git rev-parse mesg-with-cherry-footer^0) &&
 	git cherry-pick -x mesg-with-cherry-footer &&
 	cat <<-EOF >expect &&
 		$mesg_with_cherry_footer
@@ -223,7 +223,7 @@ test_expect_success 'cherry-pick -s treats "(cherry picked from..." line as part
 
 test_expect_success 'cherry-pick -x -s treats "(cherry picked from..." line as part of footer' '
 	pristine_detach initial &&
-	sha1=`git rev-parse mesg-with-cherry-footer^0` &&
+	sha1=$(git rev-parse mesg-with-cherry-footer^0) &&
 	git cherry-pick -x -s mesg-with-cherry-footer &&
 	cat <<-EOF >expect &&
 		$mesg_with_cherry_footer
-- 
2.3.3.GIT
Previous: Elia PintoNext: Elia Pinto
Message 5 of 16 in “use the $( ... ) construct for command substitution”
  1. 00/10 use the $( ... ) construct for command substitutionElia Pinto, Dec 22, 2015
  2. 01/10 t3101-ls-tree-dirname.sh: use the $( ... ) construct for command substitutionElia Pinto, Dec 22, 2015
  3. 02/10 t3210-pack-refs.sh: use the $( ... ) construct for command substitutionElia Pinto, Dec 22, 2015
  4. 03/10 t3403-rebase-skip.sh: use the $( ... ) construct for command substitutionElia Pinto, Dec 22, 2015
  5. 04/10 t3511-cherry-pick-x.sh: use the $( ... ) construct for command substitutionElia Pinto, Dec 22, 2015
  6. 05/10 t3600-rm.sh: use the $( ... ) construct for command substitutionElia Pinto, Dec 22, 2015
  7. 06/10 t3700-add.sh: use the $( ... ) construct for command substitutionElia Pinto, Dec 22, 2015
  8. 07/10 t5100-mailinfo.sh: use the $( ... ) construct for command substitutionElia Pinto, Dec 22, 2015
  9. Johannes SixtDec 22, 2015
  10. Johannes SixtDec 22, 2015
  11. Junio C HamanoDec 27, 2015
  12. Junio C HamanoDec 28, 2015
  13. Johannes SixtDec 28, 2015
  14. 08/10 t5300-pack-object.sh: use the $( ... ) construct for command substitutionElia Pinto, Dec 22, 2015
  15. 09/10 t5301-sliding-window.sh: use the $( ... ) construct for command substitutionElia Pinto, Dec 22, 2015
  16. 10/10 t5302-pack-index.sh: use the $( ... ) construct for command substitutionElia Pinto, Dec 22, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.