From: Chris Ridd Date: Wed, 11 Jun 2008 13:09:19 +0000 (+0100) Subject: Improve sed portability X-Git-Tag: v1.5.6-rc3~21 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fe22e5420ee547bac58481ed1a868f4cd39ad128;p=git.git Improve sed portability The behaviour of "sed" on an incomplete line is unspecified by POSIX, and On Solaris it apparently fails to process input that doesn't end in a LF. Consequently constructs like re=$(printf '%s' foo | sed -e 's/bar/BAR/g' $) cause re to be set to the empty string. Such a construct is used in git-submodule.sh. Because the LF at the end of command output are stripped away by the command substitution, it is a safe and sane change to add a LF at the end of the printf format specifier. Signed-off-by: Chris Ridd Signed-off-by: Junio C Hamano --- diff --git a/git-submodule.sh b/git-submodule.sh index 100737210..403283090 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -73,7 +73,7 @@ resolve_relative_url () module_name() { # Do we have "submodule..path = $1" defined in .gitmodules file? - re=$(printf '%s' "$1" | sed -e 's/[].[^$\\*]/\\&/g') + re=$(printf '%s\n' "$1" | sed -e 's/[].[^$\\*]/\\&/g') name=$( git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' ) test -z "$name" &&