git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Improve sed portability
@ 2008-06-11 13:09 Chris Ridd
  2008-06-11 14:04 ` Johannes Sixt
  0 siblings, 1 reply; 9+ messages in thread
From: Chris Ridd @ 2008-06-11 13:09 UTC (permalink / raw)
  To: git; +Cc: Chris Ridd

On Solaris /usr/bin/sed apparently fails to process input that doesn't
end in a \n. 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.

Changing the printf to add a \n seems the safest change. The
POSIX-compliant seds shipped with Solaris do not have this problem.

Signed-off-by: Chris Ridd <chris.ridd@isode.com>
---
 git-submodule.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 1007372..e515bcc 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -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" &&
-- 
1.5.3.6

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-07-13 20:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-11 13:09 [PATCH] Improve sed portability Chris Ridd
2008-06-11 14:04 ` Johannes Sixt
2008-06-11 15:29   ` Chris Ridd
2008-06-11 16:39     ` Jeff King
2008-06-12  7:46     ` Johannes Sixt
2008-06-12  8:29       ` Chris Ridd
2008-06-12  9:07         ` Jeff King
2008-07-13 20:00     ` Jakub Narebski
2008-06-12  8:33   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).