git-clone.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
add77e8400252ef59441770a96379dcad797b649
1 file changed
+10
-10
contrib/examples/git-clone.sh
+10
-10
@@ -40,7 +40,7 @@ eval "$(echo "$OPTIONS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)
40
41
get_repo_base() {
42
(
43
- cd "`/bin/pwd`" &&
43
+ cd "$(/bin/pwd)" &&
44
cd "$1" || cd "$1.git" &&
45
{
46
cd .git
@@ -50,7 +50,7 @@ get_repo_base() {
50
}
51
52
if [ -n "$GIT_SSL_NO_VERIFY" -o \
53
- "`git config --bool http.sslVerify`" = false ]; then
53
+ "$(git config --bool http.sslVerify)" = false ]; then
54
curl_extra_args="-k"
55
fi
56
@@ -70,7 +70,7 @@ clone_dumb_http () {
70
clone_tmp="$GIT_DIR/clone-tmp" &&
71
mkdir -p "$clone_tmp" || exit 1
72
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
73
- "`git config --bool http.noEPSV`" = true ]; then
73
+ "$(git config --bool http.noEPSV)" = true ]; then
74
curl_extra_args="${curl_extra_args} --disable-epsv"
75
fi
76
http_fetch "$1/info/refs" "$clone_tmp/refs" ||
@@ -79,7 +79,7 @@ Perhaps git-update-server-info needs to be run there?"
79
test "z$quiet" = z && v=-v || v=
80
while read sha1 refname
81
do
82
- name=`expr "z$refname" : 'zrefs/\(.*\)'` &&
82
+ name=$(expr "z$refname" : 'zrefs/\(.*\)') &&
83
case "$name" in
84
*^*) continue;;
85
esac
@@ -88,7 +88,7 @@ Perhaps git-update-server-info needs to be run there?"
88
*) continue ;;
89
esac
90
if test -n "$use_separate_remote" &&
91
- branch_name=`expr "z$name" : 'zheads/\(.*\)'`
91
+ branch_name=$(expr "z$name" : 'zheads/\(.*\)')
92
then
93
tname="remotes/$origin/$branch_name"
94
else
@@ -100,7 +100,7 @@ Perhaps git-update-server-info needs to be run there?"
100
http_fetch "$1/HEAD" "$GIT_DIR/REMOTE_HEAD" ||
101
rm -f "$GIT_DIR/REMOTE_HEAD"
102
if test -f "$GIT_DIR/REMOTE_HEAD"; then
103
- head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
103
+ head_sha1=$(cat "$GIT_DIR/REMOTE_HEAD")
104
case "$head_sha1" in
105
'ref: refs/'*)
106
;;
@@ -444,15 +444,15 @@ then
444
# a non-bare repository is always in separate-remote layout
445
remote_top="refs/remotes/$origin"
446
head_sha1=
447
- test ! -r "$GIT_DIR/REMOTE_HEAD" || head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
447
+ test ! -r "$GIT_DIR/REMOTE_HEAD" || head_sha1=$(cat "$GIT_DIR/REMOTE_HEAD")
448
case "$head_sha1" in
449
'ref: refs/'*)
450
# Uh-oh, the remote told us (http transport done against
451
# new style repository with a symref HEAD).
452
# Ideally we should skip the guesswork but for now
453
# opt for minimum change.
454
- head_sha1=`expr "z$head_sha1" : 'zref: refs/heads/\(.*\)'`
455
- head_sha1=`cat "$GIT_DIR/$remote_top/$head_sha1"`
454
+ head_sha1=$(expr "z$head_sha1" : 'zref: refs/heads/\(.*\)')
455
+ head_sha1=$(cat "$GIT_DIR/$remote_top/$head_sha1")
456
;;
457
esac
458
@@ -467,7 +467,7 @@ then
467
while read name
468
do
469
test t = $done && continue
470
- branch_tip=`cat "$GIT_DIR/$remote_top/$name"`
470
+ branch_tip=$(cat "$GIT_DIR/$remote_top/$name")
471
if test "$head_sha1" = "$branch_tip"
472
then
473
echo "$name"