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

[PATCH 002/14] install-webdoc.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-2-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>
---
 Documentation/install-webdoc.sh |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Documentation/install-webdoc.sh b/Documentation/install-webdoc.sh
index 76d69a9..ed8b4ff 100755
--- a/Documentation/install-webdoc.sh
+++ b/Documentation/install-webdoc.sh
@@ -18,17 +18,17 @@ do
 	else
 		echo >&2 "# install $h $T/$h"
 		rm -f "$T/$h"
-		mkdir -p `dirname "$T/$h"`
+		mkdir -p $(dirname "$T/$h")
 		cp "$h" "$T/$h"
 	fi
 done
-strip_leading=`echo "$T/" | sed -e 's|.|.|g'`
+strip_leading=$(echo "$T/" | sed -e 's|.|.|g')
 for th in \
 	"$T"/*.html "$T"/*.txt \
 	"$T"/howto/*.txt "$T"/howto/*.html \
 	"$T"/technical/*.txt "$T"/technical/*.html
 do
-	h=`expr "$th" : "$strip_leading"'\(.*\)'`
+	h=$(expr "$th" : "$strip_leading"'\(.*\)')
 	case "$h" in
 	RelNotes-*.txt | index.html) continue ;;
 	esac
-- 
1.7.10.4
Previous: Elia PintoNext: Elia Pinto
Message 2 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.