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 <gitster@pobox.com>

Junio C Hamano committed Jun 10, 2014 at 08:33 UTC 6a0662304d85ffa288c960f688eb9704954ea8ee
1 file changed +8 -8
git-submodule.sh
+8 -8
@@ -235,7 +235,7 @@ module_name()
235 sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' )
236 test -z "$name" &&
237 die "$(eval_gettext "No submodule mapping found in .gitmodules for path '\$sm_path'")"
238 - echo "$name"
238 + printf '%s\n' "$name"
239 }
240
241 #
@@ -305,10 +305,10 @@ module_clone()
305 b=${b%/}
306
307 # 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"
310
311 - rel=$(echo $a | sed -e 's|[^/][^/]*|..|g')
311 + rel=$(printf '%s\n' "$a" | sed -e 's|[^/][^/]*|..|g')
312 (clear_local_git_env; cd "$sm_path" && GIT_WORK_TREE=. git config core.worktree "$rel/$b")
313 }
314
@@ -389,7 +389,7 @@ cmd_add()
389 sm_path=$2
390
391 if test -z "$sm_path"; then
392 - sm_path=$(echo "$repo" |
392 + sm_path=$(printf '%s\n' "$repo" |
393 sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
394 fi
395
@@ -1058,7 +1058,7 @@ cmd_summary() {
1058 # Always show modules deleted or type-changed (blob<->module)
1059 if test "$status" = D || test "$status" = T
1060 then
1061 - echo "$sm_path"
1061 + printf '%s\n' "$sm_path"
1062 continue
1063 fi
1064 # Respect the ignore setting for --for-status.
@@ -1070,7 +1070,7 @@ cmd_summary() {
1070 fi
1071 # Also show added or modified modules which are checked out
1072 GIT_DIR="$sm_path/.git" git-rev-parse --git-dir >/dev/null 2>&1 &&
1073 - echo "$sm_path"
1073 + printf '%s\n' "$sm_path"
1074 done
1075 )
1076
@@ -1311,7 +1311,7 @@ cmd_sync()
1311 ./*|../*)
1312 # rewrite foo/bar as ../.. to find path from
1313 # 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")" &&
1315 # guarantee a trailing /
1316 up_path=${up_path%/}/ &&
1317 # path from submodule work tree to submodule origin repo