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

[PATCH 008/14] git-merge.sh: use the $( ... ) construct for command substitution

From
Elia Pinto <gitter.spiros@gmail.com>
Date
Apr 16, 2014, 17:29 UTC
Message-ID
<1397669398-25410-8-git-send-email-gitter.spiros@gmail.com>
In-Reply-To
<1397669398-25410-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
   sed -i 's@`\(.*\)`@$(\1)@g' ${_f}
done
and then carefully proof-read.
Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 contrib/examples/git-merge.sh |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/examples/git-merge.sh b/contrib/examples/git-merge.sh
index a5e42a9..7e40f40 100755
--- a/contrib/examples/git-merge.sh
+++ b/contrib/examples/git-merge.sh
@@ -341,7 +341,7 @@ case "$use_strategies" in
 '')
 	case "$#" in
 	1)
-		var="`git config --get pull.twohead`"
+		var="$(git config --get pull.twohead)"
 		if test -n "$var"
 		then
 			use_strategies="$var"
@@ -349,7 +349,7 @@ case "$use_strategies" in
 			use_strategies="$default_twohead_strategies"
 		fi ;;
 	*)
-		var="`git config --get pull.octopus`"
+		var="$(git config --get pull.octopus)"
 		if test -n "$var"
 		then
 			use_strategies="$var"
-- 
1.7.10.4
Previous: Elia PintoNext: Elia Pinto
Message 8 of 16 in “howto-index.sh: use the $( ... ) construct for command substitution”
  1. 001/14 howto-index.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  2. 002/14 install-webdoc.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  3. 003/14 git-checkout.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  4. 004/14 git-clone.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  5. 005/14 git-commit.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  6. 006/14 git-fetch.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  7. 007/14 git-ls-remote.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  8. 008/14 git-merge.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  9. 009/14 git-repack.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  10. 010/14 git-resolve.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  11. 011/14 git-revert.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  12. 012/14 git-tag.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  13. 013/14 t9360-mw-to-git-clone.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  14. 014/14 t9362-mw-to-git-utf8.sh: use the $( ... ) construct for command substitutionElia Pinto, Apr 16, 2014
  15. Matthieu MoyApr 17, 2014
  16. Junio C HamanoApr 17, 2014

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.