git-am.sh: use the $(...) construct for command substitution

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elia Pinto committed Mar 25, 2014 at 10:22 UTC 75ee3d7078fbcc3b87a3ae5e0cf42f46256c5da4
1 file changed +15 -15
git-am.sh
+15 -15
@@ -125,7 +125,7 @@ cannot_fallback () {
125 }
126
127 fall_back_3way () {
128 - O_OBJECT=`cd "$GIT_OBJECT_DIRECTORY" && pwd`
128 + O_OBJECT=$(cd "$GIT_OBJECT_DIRECTORY" && pwd)
129
130 rm -fr "$dotest"/patch-merge-*
131 mkdir "$dotest/patch-merge-tmp-dir"
@@ -275,7 +275,7 @@ split_patches () {
275 then
276 clean_abort "$(gettext "Only one StGIT patch series can be applied at once")"
277 fi
278 - series_dir=`dirname "$1"`
278 + series_dir=$(dirname "$1")
279 series_file="$1"
280 shift
281 {
@@ -298,8 +298,8 @@ split_patches () {
298 this=0
299 for stgit in "$@"
300 do
301 - this=`expr "$this" + 1`
302 - msgnum=`printf "%0${prec}d" $this`
301 + this=$(expr "$this" + 1)
302 + msgnum=$(printf "%0${prec}d" $this)
303 # Perl version of StGIT parse_patch. The first nonemptyline
304 # not starting with Author, From or Date is the
305 # subject, and the body starts with the next nonempty
@@ -644,26 +644,26 @@ fi
644 git_apply_opt=$(cat "$dotest/apply-opt")
645 if test "$(cat "$dotest/sign")" = t
646 then
647 - SIGNOFF=`git var GIT_COMMITTER_IDENT | sed -e '
647 + SIGNOFF=$(git var GIT_COMMITTER_IDENT | sed -e '
648 s/>.*/>/
649 s/^/Signed-off-by: /'
650 - `
650 + )
651 else
652 SIGNOFF=
653 fi
654
655 -last=`cat "$dotest/last"`
656 -this=`cat "$dotest/next"`
655 +last=$(cat "$dotest/last")
656 +this=$(cat "$dotest/next")
657 if test "$skip" = t
658 then
659 - this=`expr "$this" + 1`
659 + this=$(expr "$this" + 1)
660 resume=
661 fi
662
663 while test "$this" -le "$last"
664 do
665 - msgnum=`printf "%0${prec}d" $this`
666 - next=`expr "$this" + 1`
665 + msgnum=$(printf "%0${prec}d" $this)
666 + next=$(expr "$this" + 1)
667 test -f "$dotest/$msgnum" || {
668 resume=
669 go_next
@@ -739,16 +739,16 @@ To restore the original branch and stop patching run \"\$cmdline --abort\"."
739 '')
740 if test '' != "$SIGNOFF"
741 then
742 - LAST_SIGNED_OFF_BY=`
742 + LAST_SIGNED_OFF_BY=$(
743 sed -ne '/^Signed-off-by: /p' \
744 "$dotest/msg-clean" |
745 sed -ne '$p'
746 - `
747 - ADD_SIGNOFF=`
746 + )
747 + ADD_SIGNOFF=$(
748 test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || {
749 test '' = "$LAST_SIGNED_OFF_BY" && echo
750 echo "$SIGNOFF"
751 - }`
751 + })
752 else
753 ADD_SIGNOFF=
754 fi