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

[PATCH 010/14] git-resolve.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-10-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-resolve.sh |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/examples/git-resolve.sh b/contrib/examples/git-resolve.sh
index 8f98142..48d0fc9 100755
--- a/contrib/examples/git-resolve.sh
+++ b/contrib/examples/git-resolve.sh
@@ -75,7 +75,7 @@ case "$common" in
 		GIT_INDEX_FILE=$G git read-tree -m $c $head $merge \
 			2>/dev/null || continue
 		# Count the paths that are unmerged.
-		cnt=`GIT_INDEX_FILE=$G git ls-files --unmerged | wc -l`
+		cnt=$(GIT_INDEX_FILE=$G git ls-files --unmerged | wc -l)
 		if test $best_cnt -le 0 -o $cnt -le $best_cnt
 		then
 			best=$c
-- 
1.7.10.4
Previous: Elia PintoNext: Elia Pinto
Message 10 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.