OSDN Git Service

t/t1512-rev-parse-disambiguation.sh: use the $( ... ) construct for command substitution
authorElia Pinto <gitter.spiros@gmail.com>
Tue, 22 Dec 2015 15:05:50 +0000 (16:05 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 27 Dec 2015 23:44:49 +0000 (15:44 -0800)
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
perl -i -pe 'BEGIN{undef $/;} s/`(.+?)`/\$(\1)/smg'  "${_f}"
done

and then carefully proof-read.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1512-rev-parse-disambiguation.sh

index 4a155c8..e221167 100755 (executable)
@@ -275,19 +275,19 @@ test_expect_success 'rev-parse --disambiguate' '
 
 test_expect_success 'ambiguous 40-hex ref' '
        TREE=$(git mktree </dev/null) &&
-       REF=`git rev-parse HEAD` &&
+       REF=$(git rev-parse HEAD) &&
        VAL=$(git commit-tree $TREE </dev/null) &&
        git update-ref refs/heads/$REF $VAL &&
-       test `git rev-parse $REF 2>err` = $REF &&
+       test $(git rev-parse $REF 2>err) = $REF &&
        grep "refname.*${REF}.*ambiguous" err
 '
 
 test_expect_success 'ambiguous short sha1 ref' '
        TREE=$(git mktree </dev/null) &&
-       REF=`git rev-parse --short HEAD` &&
+       REF=$(git rev-parse --short HEAD) &&
        VAL=$(git commit-tree $TREE </dev/null) &&
        git update-ref refs/heads/$REF $VAL &&
-       test `git rev-parse $REF 2>err` = $VAL &&
+       test $(git rev-parse $REF 2>err) = $VAL &&
        grep "refname.*${REF}.*ambiguous" err
 '