Skip to content

Commit 6a06623

Browse files
committed
git-submodule.sh: avoid "echo" path-like values
SysV-derived implementation of "echo" interprets some backslash sequences as special instruction, e.g. "echo 'ab\c'" shows an incomplete line with 'a' and 'b' on it. Avoid using it when showing a path-like values in the script. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 496eeeb commit 6a06623

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

git-submodule.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ module_name()
235235
sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' )
236236
test -z "$name" &&
237237
die "$(eval_gettext "No submodule mapping found in .gitmodules for path '\$sm_path'")"
238-
echo "$name"
238+
printf '%s\n' "$name"
239239
}
240240

241241
#
@@ -305,10 +305,10 @@ module_clone()
305305
b=${b%/}
306306

307307
# Turn each leading "*/" component into "../"
308-
rel=$(echo $b | sed -e 's|[^/][^/]*|..|g')
309-
echo "gitdir: $rel/$a" >"$sm_path/.git"
308+
rel=$(printf '%s\n' "$b" | sed -e 's|[^/][^/]*|..|g')
309+
printf '%s\n' "gitdir: $rel/$a" >"$sm_path/.git"
310310

311-
rel=$(echo $a | sed -e 's|[^/][^/]*|..|g')
311+
rel=$(printf '%s\n' "$a" | sed -e 's|[^/][^/]*|..|g')
312312
(clear_local_git_env; cd "$sm_path" && GIT_WORK_TREE=. git config core.worktree "$rel/$b")
313313
}
314314

@@ -389,7 +389,7 @@ cmd_add()
389389
sm_path=$2
390390

391391
if test -z "$sm_path"; then
392-
sm_path=$(echo "$repo" |
392+
sm_path=$(printf '%s\n' "$repo" |
393393
sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
394394
fi
395395

@@ -1058,7 +1058,7 @@ cmd_summary() {
10581058
# Always show modules deleted or type-changed (blob<->module)
10591059
if test "$status" = D || test "$status" = T
10601060
then
1061-
echo "$sm_path"
1061+
printf '%s\n' "$sm_path"
10621062
continue
10631063
fi
10641064
# Respect the ignore setting for --for-status.
@@ -1070,7 +1070,7 @@ cmd_summary() {
10701070
fi
10711071
# Also show added or modified modules which are checked out
10721072
GIT_DIR="$sm_path/.git" git-rev-parse --git-dir >/dev/null 2>&1 &&
1073-
echo "$sm_path"
1073+
printf '%s\n' "$sm_path"
10741074
done
10751075
)
10761076

@@ -1311,7 +1311,7 @@ cmd_sync()
13111311
./*|../*)
13121312
# rewrite foo/bar as ../.. to find path from
13131313
# submodule work tree to superproject work tree
1314-
up_path="$(echo "$sm_path" | sed "s/[^/][^/]*/../g")" &&
1314+
up_path="$(printf '%s\n' "$sm_path" | sed "s/[^/][^/]*/../g")" &&
13151315
# guarantee a trailing /
13161316
up_path=${up_path%/}/ &&
13171317
# path from submodule work tree to submodule origin repo

0 commit comments

Comments
 (0)