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

[PATCH 007/14] git-ls-remote.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-7-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-ls-remote.sh |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/examples/git-ls-remote.sh b/contrib/examples/git-ls-remote.sh
index fec70bb..2aa89a7 100755
--- a/contrib/examples/git-ls-remote.sh
+++ b/contrib/examples/git-ls-remote.sh
@@ -55,11 +55,11 @@ tmpdir=$tmp-d
 case "$peek_repo" in
 http://* | https://* | ftp://* )
 	if [ -n "$GIT_SSL_NO_VERIFY" -o \
-		"`git config --bool http.sslVerify`" = false ]; then
+		"$(git config --bool http.sslVerify)" = false ]; then
 		curl_extra_args="-k"
 	fi
 	if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
-		"`git config --bool http.noEPSV`" = true ]; then
+		"$(git config --bool http.noEPSV)" = true ]; then
 		curl_extra_args="${curl_extra_args} --disable-epsv"
 	fi
 	curl -nsf $curl_extra_args --header "Pragma: no-cache" "$peek_repo/info/refs" ||
-- 
1.7.10.4
Previous: Elia PintoNext: Elia Pinto
Message 7 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.