git-checkout.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> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elia Pinto committed Apr 16, 2014 at 10:29 UTC 844cb24f28afd4febcfc1ddc44f9de47130acf4b
1 file changed +4 -4
contrib/examples/git-checkout.sh
+4 -4
@@ -222,7 +222,7 @@ else
222
223 # Match the index to the working tree, and do a three-way.
224 git diff-files --name-only | git update-index --remove --stdin &&
225 - work=`git write-tree` &&
225 + work=$(git write-tree) &&
226 git read-tree $v --reset -u $new || exit
227
228 eval GITHEAD_$new='${new_name:-${branch:-$new}}' &&
@@ -233,7 +233,7 @@ else
233 # Do not register the cleanly merged paths in the index yet.
234 # this is not a real merge before committing, but just carrying
235 # the working tree changes along.
236 - unmerged=`git ls-files -u`
236 + unmerged=$(git ls-files -u)
237 git read-tree $v --reset $new
238 case "$unmerged" in
239 '') ;;
@@ -269,7 +269,7 @@ if [ "$?" -eq 0 ]; then
269 fi
270 if test -n "$branch"
271 then
272 - old_branch_name=`expr "z$oldbranch" : 'zrefs/heads/\(.*\)'`
272 + old_branch_name=$(expr "z$oldbranch" : 'zrefs/heads/\(.*\)')
273 GIT_DIR="$GIT_DIR" git symbolic-ref -m "checkout: moving from ${old_branch_name:-$old} to $branch" HEAD "refs/heads/$branch"
274 if test -n "$quiet"
275 then
@@ -282,7 +282,7 @@ if [ "$?" -eq 0 ]; then
282 fi
283 elif test -n "$detached"
284 then
285 - old_branch_name=`expr "z$oldbranch" : 'zrefs/heads/\(.*\)'`
285 + old_branch_name=$(expr "z$oldbranch" : 'zrefs/heads/\(.*\)')
286 git update-ref --no-deref -m "checkout: moving from ${old_branch_name:-$old} to $arg" HEAD "$detached" ||
287 die "Cannot detach HEAD"
288 if test -n "$detach_warn"