Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit add77e8

Browse files
devzero2000gitster
authored andcommitted
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 <[email protected]> Reviewed-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 844cb24 commit add77e8

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

contrib/examples/git-clone.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ eval "$(echo "$OPTIONS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)
4040

4141
get_repo_base() {
4242
(
43-
cd "`/bin/pwd`" &&
43+
cd "$(/bin/pwd)" &&
4444
cd "$1" || cd "$1.git" &&
4545
{
4646
cd .git
@@ -50,7 +50,7 @@ get_repo_base() {
5050
}
5151

5252
if [ -n "$GIT_SSL_NO_VERIFY" -o \
53-
"`git config --bool http.sslVerify`" = false ]; then
53+
"$(git config --bool http.sslVerify)" = false ]; then
5454
curl_extra_args="-k"
5555
fi
5656

@@ -70,7 +70,7 @@ clone_dumb_http () {
7070
clone_tmp="$GIT_DIR/clone-tmp" &&
7171
mkdir -p "$clone_tmp" || exit 1
7272
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
73-
"`git config --bool http.noEPSV`" = true ]; then
73+
"$(git config --bool http.noEPSV)" = true ]; then
7474
curl_extra_args="${curl_extra_args} --disable-epsv"
7575
fi
7676
http_fetch "$1/info/refs" "$clone_tmp/refs" ||
@@ -79,7 +79,7 @@ Perhaps git-update-server-info needs to be run there?"
7979
test "z$quiet" = z && v=-v || v=
8080
while read sha1 refname
8181
do
82-
name=`expr "z$refname" : 'zrefs/\(.*\)'` &&
82+
name=$(expr "z$refname" : 'zrefs/\(.*\)') &&
8383
case "$name" in
8484
*^*) continue;;
8585
esac
@@ -88,7 +88,7 @@ Perhaps git-update-server-info needs to be run there?"
8888
*) continue ;;
8989
esac
9090
if test -n "$use_separate_remote" &&
91-
branch_name=`expr "z$name" : 'zheads/\(.*\)'`
91+
branch_name=$(expr "z$name" : 'zheads/\(.*\)')
9292
then
9393
tname="remotes/$origin/$branch_name"
9494
else
@@ -100,7 +100,7 @@ Perhaps git-update-server-info needs to be run there?"
100100
http_fetch "$1/HEAD" "$GIT_DIR/REMOTE_HEAD" ||
101101
rm -f "$GIT_DIR/REMOTE_HEAD"
102102
if test -f "$GIT_DIR/REMOTE_HEAD"; then
103-
head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
103+
head_sha1=$(cat "$GIT_DIR/REMOTE_HEAD")
104104
case "$head_sha1" in
105105
'ref: refs/'*)
106106
;;
@@ -444,15 +444,15 @@ then
444444
# a non-bare repository is always in separate-remote layout
445445
remote_top="refs/remotes/$origin"
446446
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")
448448
case "$head_sha1" in
449449
'ref: refs/'*)
450450
# Uh-oh, the remote told us (http transport done against
451451
# new style repository with a symref HEAD).
452452
# Ideally we should skip the guesswork but for now
453453
# 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")
456456
;;
457457
esac
458458

@@ -467,7 +467,7 @@ then
467467
while read name
468468
do
469469
test t = $done && continue
470-
branch_tip=`cat "$GIT_DIR/$remote_top/$name"`
470+
branch_tip=$(cat "$GIT_DIR/$remote_top/$name")
471471
if test "$head_sha1" = "$branch_tip"
472472
then
473473
echo "$name"

0 commit comments

Comments
 (0)