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

Commit

Permalink
Improve sed portability
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Chris Ridd authored and gitster committed Jun 13, 2008
1 parent 4209752 commit fe22e54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion git-submodule.sh
Expand Up @@ -73,7 +73,7 @@ resolve_relative_url ()
module_name()
{
# Do we have "submodule.<something>.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" &&
Expand Down

0 comments on commit fe22e54

Please sign in to comment.