Skip to content

Commit

Permalink
t1020-subdirectory.sh: use the $( ... ) construct for command substit…
Browse files Browse the repository at this point in the history
…ution

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>
  • Loading branch information
Elia Pinto authored and Junio C Hamano committed Apr 29, 2014
1 parent 77317c0 commit c9e454c
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions t/t1020-subdirectory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ test_expect_success setup '

test_expect_success 'update-index and ls-files' '
git update-index --add one &&
case "`git ls-files`" in
case "$(git ls-files)" in
one) echo pass one ;;
*) echo bad one; exit 1 ;;
esac &&
(
cd dir &&
git update-index --add two &&
case "`git ls-files`" in
case "$(git ls-files)" in
two) echo pass two ;;
*) echo bad two; exit 1 ;;
esac
) &&
case "`git ls-files`" in
case "$(git ls-files)" in
dir/two"$LF"one) echo pass both ;;
*) echo bad; exit 1 ;;
esac
'

test_expect_success 'cat-file' '
two=`git ls-files -s dir/two` &&
two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
two=$(git ls-files -s dir/two) &&
two=$(expr "$two" : "[0-7]* \\([0-9a-f]*\\)") &&
echo "$two" &&
git cat-file -p "$two" >actual &&
cmp dir/two actual &&
Expand All @@ -55,30 +55,30 @@ rm -f actual dir/actual
test_expect_success 'diff-files' '
echo a >>one &&
echo d >>dir/two &&
case "`git diff-files --name-only`" in
case "$(git diff-files --name-only)" in
dir/two"$LF"one) echo pass top ;;
*) echo bad top; exit 1 ;;
esac &&
# diff should not omit leading paths
(
cd dir &&
case "`git diff-files --name-only`" in
case "$(git diff-files --name-only)" in
dir/two"$LF"one) echo pass subdir ;;
*) echo bad subdir; exit 1 ;;
esac &&
case "`git diff-files --name-only .`" in
case "$(git diff-files --name-only .)" in
dir/two) echo pass subdir limited ;;
*) echo bad subdir limited; exit 1 ;;
esac
)
'

test_expect_success 'write-tree' '
top=`git write-tree` &&
top=$(git write-tree) &&
echo $top &&
(
cd dir &&
sub=`git write-tree` &&
sub=$(git write-tree) &&
echo $sub &&
test "z$top" = "z$sub"
)
Expand All @@ -96,7 +96,7 @@ test_expect_success 'checkout-index' '

test_expect_success 'read-tree' '
rm -f one dir/two &&
tree=`git write-tree` &&
tree=$(git write-tree) &&
read_tree_u_must_succeed --reset -u "$tree" &&
cmp one original.one &&
cmp dir/two original.two &&
Expand Down

0 comments on commit c9e454c

Please sign in to comment.