Skip to content

Commit fe22e54

Browse files
Chris Riddgitster
authored andcommitted
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 <chris.ridd@isode.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4209752 commit fe22e54

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git-submodule.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ resolve_relative_url ()
7373
module_name()
7474
{
7575
# Do we have "submodule.<something>.path = $1" defined in .gitmodules file?
76-
re=$(printf '%s' "$1" | sed -e 's/[].[^$\\*]/\\&/g')
76+
re=$(printf '%s\n' "$1" | sed -e 's/[].[^$\\*]/\\&/g')
7777
name=$( git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
7878
sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' )
7979
test -z "$name" &&

0 commit comments

Comments
 (0)