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

[PATCH 100/144] t9104-git-svn-follow-parent.sh: use the $( ... ) construct for command substitution

From
Elia Pinto <gitter.spiros@gmail.com>
Date
Mar 25, 2014, 08:25 UTC
Message-ID
<1395735989-3396-101-git-send-email-gitter.spiros@gmail.com>
In-Reply-To
<1395735989-3396-1-git-send-email-gitter.spiros@gmail.com>

The Git CodingGuidelines prefer the $( ... ) construct for command substitution instead of using the back-quotes, or grave accents (`..`).

The backquoted form is the historical 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. Because of this the POSIX shell adopted the $(…) feature from the Korn shell.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 t/t9104-git-svn-follow-parent.sh |   48 +++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh
index 13b179e..101f545 100755
--- a/t/t9104-git-svn-follow-parent.sh
+++ b/t/t9104-git-svn-follow-parent.sh
@@ -31,8 +31,8 @@ test_expect_success 'initialize repo' '
 test_expect_success 'init and fetch a moved directory' '
 	git svn init --minimize-url -i thunk "$svnrepo"/thunk &&
 	git svn fetch -i thunk &&
-	test "`git rev-parse --verify refs/remotes/thunk@2`" \
-           = "`git rev-parse --verify refs/remotes/thunk~1`" &&
+	test "$(git rev-parse --verify refs/remotes/thunk@2)" \
+           = "$(git rev-parse --verify refs/remotes/thunk~1)" &&
         test "`git cat-file blob refs/remotes/thunk:readme |\
                  sed -n -e "3p"`" = goodbye &&
 	test -z "`git config --get svn-remote.svn.fetch \
@@ -46,8 +46,8 @@ test_expect_success 'init and fetch from one svn-remote' '
         git config --add svn-remote.svn.fetch \
           thunk:refs/remotes/svn/thunk &&
         git svn fetch -i svn/thunk &&
-	test "`git rev-parse --verify refs/remotes/svn/trunk`" \
-           = "`git rev-parse --verify refs/remotes/svn/thunk~1`" &&
+	test "$(git rev-parse --verify refs/remotes/svn/trunk)" \
+           = "$(git rev-parse --verify refs/remotes/svn/thunk~1)" &&
         test "`git cat-file blob refs/remotes/svn/thunk:readme |\
                  sed -n -e "3p"`" = goodbye
         '
@@ -61,9 +61,9 @@ test_expect_success 'follow deleted parent' '
           junk:refs/remotes/svn/junk &&
         git svn fetch -i svn/thunk &&
         git svn fetch -i svn/junk &&
-        test -z "`git diff svn/junk svn/trunk`" &&
-        test "`git merge-base svn/junk svn/trunk`" \
-           = "`git rev-parse svn/trunk`"
+        test -z "$(git diff svn/junk svn/trunk)" &&
+        test "$(git merge-base svn/junk svn/trunk)" \
+           = "$(git rev-parse svn/trunk)"
         '
 
 test_expect_success 'follow larger parent' '
@@ -80,7 +80,7 @@ test_expect_success 'follow larger parent' '
         test "`git merge-base \
                  refs/remotes/larger-parent/trunk/thunk/bump/thud \
                  refs/remotes/larger`" = \
-             "`git rev-parse refs/remotes/larger`"
+             "$(git rev-parse refs/remotes/larger)"
         true
         '
 
@@ -104,8 +104,8 @@ test_expect_success 'follow deleted directory' '
 	svn_cmd rm -m "remove glob" "$svnrepo"/glob &&
 	git svn init --minimize-url -i glob "$svnrepo"/glob &&
 	git svn fetch -i glob &&
-	test "`git cat-file blob refs/remotes/glob:blob/bye`" = hi &&
-	test "`git ls-tree refs/remotes/glob | wc -l `" -eq 1
+	test "$(git cat-file blob refs/remotes/glob:blob/bye)" = hi &&
+	test "$(git ls-tree refs/remotes/glob | wc -l )" -eq 1
 	'
 
 # ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn)
@@ -140,9 +140,9 @@ test_expect_success 'follow-parent avoids deleting relevant info' '
 	git svn init --minimize-url -i r9270-t \
 	  "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t &&
 	git svn fetch -i r9270-t &&
-	test `git rev-list r9270-t | wc -l` -eq 2 &&
-	test "`git ls-tree --name-only r9270-t~1`" = \
-	     "`git ls-tree --name-only r9270-t`"
+	test $(git rev-list r9270-t | wc -l) -eq 2 &&
+	test "$(git ls-tree --name-only r9270-t~1)" = \
+	     "$(git ls-tree --name-only r9270-t)"
 	'
 
 test_expect_success "track initial change if it was only made to parent" '
@@ -150,11 +150,11 @@ test_expect_success "track initial change if it was only made to parent" '
 	git svn init --minimize-url -i r9270-d \
 	  "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t &&
 	git svn fetch -i r9270-d &&
-	test `git rev-list r9270-d | wc -l` -eq 3 &&
-	test "`git ls-tree --name-only r9270-t`" = \
-	     "`git ls-tree --name-only r9270-d`" &&
-	test "`git rev-parse r9270-t`" = \
-	     "`git rev-parse r9270-d~1`"
+	test $(git rev-list r9270-d | wc -l) -eq 3 &&
+	test "$(git ls-tree --name-only r9270-t)" = \
+	     "$(git ls-tree --name-only r9270-d)" &&
+	test "$(git rev-parse r9270-t)" = \
+	     "$(git rev-parse r9270-d~1)"
 	'
 
 test_expect_success "follow-parent is atomic" '
@@ -191,12 +191,12 @@ test_expect_success "follow-parent is atomic" '
 	git svn fetch -i stunk &&
 	git svn init --minimize-url -i flunked "$svnrepo"/flunked &&
 	git svn fetch -i flunked &&
-	test "`git rev-parse --verify refs/remotes/flunk@18`" \
-	   = "`git rev-parse --verify refs/remotes/stunk`" &&
-	test "`git rev-parse --verify refs/remotes/flunk~1`" \
-	   = "`git rev-parse --verify refs/remotes/stunk`" &&
-	test "`git rev-parse --verify refs/remotes/flunked~1`" \
-	   = "`git rev-parse --verify refs/remotes/stunk~1`"
+	test "$(git rev-parse --verify refs/remotes/flunk@18)" \
+	   = "$(git rev-parse --verify refs/remotes/stunk)" &&
+	test "$(git rev-parse --verify refs/remotes/flunk~1)" \
+	   = "$(git rev-parse --verify refs/remotes/stunk)" &&
+	test "$(git rev-parse --verify refs/remotes/flunked~1)" \
+	   = "$(git rev-parse --verify refs/remotes/stunk~1)"
 	'
 
 test_expect_success "track multi-parent paths" '
-- 
1.7.10.4
Previous: Eric WongNext: Elia Pinto
Message 108 of 113 in “Use the $( ... ) construct for command substitution instead of using the back-quotes”
  1. 000/144 Use the $( ... ) construct for command substitution instead of using the back-quotesElia Pinto, Mar 25, 2014
  2. 001/144 check-builtins.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  3. Matthieu MoyMar 25, 2014
  4. Elia PintoMar 25, 2014
  5. 002/144 git-am.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  6. 003/144 git-pull.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  7. 004/144 git-rebase--merge.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  8. 005/144 git-rebase.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  9. 006/144 git-stash.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  10. 007/144 git-web--browse.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  11. 008/144 unimplemented.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  12. 009/144 t0001-init.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  13. 010/144 t0010-racy-git.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  14. 011/144 t0020-crlf.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  15. 012/144 t0025-crlf-auto.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  16. 013/144 t0026-eol-config.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  17. 014/144 t0030-stripspace.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  18. 015/144 t0204-gettext-reencode-sanity.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  19. Matthieu MoyMar 25, 2014
  20. Elia PintoMar 25, 2014
  21. 016/144 t0300-credentials.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  22. 017/144 t1000-read-tree-m-3way.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  23. 018/144 t1001-read-tree-m-2way.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  24. 019/144 t1002-read-tree-m-u-2way.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  25. 020/144 t1003-read-tree-prefix.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  26. 021/144 t1004-read-tree-m-u-wf.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  27. 022/144 t1020-subdirectory.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  28. 023/144 t1050-large.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  29. 024/144 t1100-commit-tree-options.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  30. 025/144 t1401-symbolic-ref.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  31. 026/144 t1410-reflog.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  32. 027/144 t1511-rev-parse-caret.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  33. 028/144 t1512-rev-parse-disambiguation.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  34. 029/144 t2102-update-index-symlinks.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  35. 030/144 t3030-merge-recursive.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  36. 031/144 t3100-ls-tree-restrict.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  37. 032/144 t3101-ls-tree-dirname.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  38. 033/144 t3210-pack-refs.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  39. 034/144 t3403-rebase-skip.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  40. 035/144 t3511-cherry-pick-x.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  41. 036/144 t3600-rm.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  42. 037/144 t3700-add.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  43. 038/144 t3905-stash-include-untracked.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  44. 039/144 t3910-mac-os-precompose.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  45. 040/144 t4006-diff-mode.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  46. 041/144 t4010-diff-pathspec.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  47. 042/144 t4012-diff-binary.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  48. 043/144 t4013-diff-various.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  49. 044/144 t4014-format-patch.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  50. 045/144 t4036-format-patch-signer-mime.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  51. 046/144 t4038-diff-combined.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  52. 047/144 t4057-diff-combined-paths.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  53. 048/144 t4116-apply-reverse.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  54. 049/144 t4119-apply-config.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  55. 050/144 t4204-patch-id.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  56. 051/144 t5000-tar-tree.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  57. 052/144 t5003-archive-zip.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  58. 053/144 t5100-mailinfo.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  59. 054/144 t5300-pack-object.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  60. 055/144 t5301-sliding-window.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  61. 056/144 t5302-pack-index.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  62. 057/144 t5303-pack-corruption-resilience.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  63. 058/144 t5304-prune.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  64. 059/144 t5305-include-tag.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  65. 060/144 t5500-fetch-pack.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  66. 061/144 t5505-remote.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  67. 062/144 t5506-remote-groups.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  68. 063/144 t5510-fetch.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  69. 064/144 t5515-fetch-merge-logic.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  70. 065/144 t5516-fetch-push.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  71. 066/144 t5517-push-mirror.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  72. 067/144 t5520-pull.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  73. 068/144 t5522-pull-symlink.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  74. 069/144 t5530-upload-pack-error.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  75. 070/144 t5537-fetch-shallow.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  76. 071/144 t5538-push-shallow.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  77. 072/144 t5550-http-fetch-dumb.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  78. 073/144 t5551-http-fetch-smart.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  79. 074/144 t5570-git-daemon.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  80. 075/144 t5601-clone.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  81. 076/144 t5700-clone-reference.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  82. 077/144 t5710-info-alternate.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  83. 078/144 t5900-repo-selection.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  84. 079/144 t6001-rev-list-graft.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  85. 080/144 t6002-rev-list-bisect.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  86. 081/144 t6015-rev-list-show-all-parents.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  87. 082/144 t6032-merge-large-rename.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  88. 083/144 t6034-merge-rename-nocruft.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  89. 084/144 t6111-rev-list-treesame.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  90. Matthieu MoyMar 25, 2014
  91. Elia PintoMar 25, 2014
  92. 085/144 t6132-pathspec-exclude.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  93. 086/144 t7001-mv.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  94. 087/144 t7003-filter-branch.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  95. 088/144 t7004-tag.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  96. 089/144 t7006-pager.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  97. 090/144 t7103-reset-bare.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  98. 091/144 t7406-submodule-update.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  99. 092/144 t7408-submodule-reference.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  100. 093/144 t7504-commit-msg-hook.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  101. 094/144 t7505-prepare-commit-msg-hook.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  102. 095/144 t7602-merge-octopus-many.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  103. 096/144 t7700-repack.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  104. 097/144 t8003-blame-corner-cases.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  105. 098/144 t9001-send-email.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  106. 099/144 t9101-git-svn-props.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  107. Eric WongMar 29, 2014
  108. 100/144 t9104-git-svn-follow-parent.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  109. 101/144 t9105-git-svn-commit-diff.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  110. 102/144 t9107-git-svn-migrate.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  111. 103/144 t9108-git-svn-glob.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  112. 104/144 t9109-git-svn-multi-glob.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 2014
  113. 105/144 t9110-git-svn-use-svm-props.sh: use the $( ... ) construct for command substitutionElia Pinto, Mar 25, 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.