# [PATCH] Minor portability patch to git-submodule

4 messages from 2007-12-17 to 2007-12-18. Participants: Andy Dougherty, Johannes Schindelin.
Thread: https://gitlist.dev/t/11329

## Andy Dougherty, 2007-12-17 21:41

Subject: [PATCH] Minor portability patch to git-submodule
Message-ID: <Pine.LNX.4.64.0712171639420.24957@fractal.phys.lafayette.edu>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0712171639420.24957%40fractal.phys.lafayette.edu

```
While trying git out on Solaris 8, I needed the following patch.  
The 'grep' command on Solaris doesn't understand the -e option, though 
egrep does. 

More mysterious is the printf patch.  Without it, the sed command didn't 
match anything.

--- git-1.5.4.rc0/git-submodule.sh	Wed Dec 12 21:29:16 2007
+++ git-andy/git-submodule.sh	Mon Dec 17 14:30:46 2007
@@ -74,7 +74,7 @@
 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=.gitmodules \
 		git config --get-regexp '^submodule\..*\.path$' |
 		sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' )
@@ -176,7 +176,7 @@
 #
 modules_init()
 {
-	git ls-files --stage -- "$@" | grep -e '^160000 ' |
+	git ls-files --stage -- "$@" | egrep -e '^160000 ' |
 	while read mode sha1 stage path
 	do
 		# Skip already registered paths
@@ -209,7 +209,7 @@
 #
 modules_update()
 {
-	git ls-files --stage -- "$@" | grep -e '^160000 ' |
+	git ls-files --stage -- "$@" | egrep -e '^160000 ' |
 	while read mode sha1 stage path
 	do
 		name=$(module_name "$path") || exit
@@ -268,7 +268,7 @@
 #
 modules_list()
 {
-	git ls-files --stage -- "$@" | grep -e '^160000 ' |
+	git ls-files --stage -- "$@" | egrep -e '^160000 ' |
 	while read mode sha1 stage path
 	do
 		name=$(module_name "$path") || exit

-- 
    Andy Dougherty		doughera@lafayette.edu

```

## Johannes Schindelin, 2007-12-17 22:54

Subject: Re: [PATCH] Minor portability patch to git-submodule
Message-ID: <Pine.LNX.4.64.0712172253150.9446@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0712172253150.9446%40racer.site
In-Reply-To: <Pine.LNX.4.64.0712171639420.24957@fractal.phys.lafayette.edu>

```
Hi,

On Mon, 17 Dec 2007, Andy Dougherty wrote:

> -	git ls-files --stage -- "$@" | grep -e '^160000 ' |
> +	git ls-files --stage -- "$@" | egrep -e '^160000 ' |

Nack.  egrep is not available on all platforms.  But then I have to wonder 
why not saying "grep '^160000 '" instead?

Ciao,
Dscho

```

## Andy Dougherty, 2007-12-18 13:35

Subject: Re: [PATCH] Minor portability patch to git-submodule
Message-ID: <Pine.LNX.4.64.0712180734520.28219@fractal.phys.lafayette.edu>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0712180734520.28219%40fractal.phys.lafayette.edu
In-Reply-To: <Pine.LNX.4.64.0712172253150.9446@racer.site>

```
On Mon, 17 Dec 2007, Johannes Schindelin wrote:

> On Mon, 17 Dec 2007, Andy Dougherty wrote:
> 
> > -	git ls-files --stage -- "$@" | grep -e '^160000 ' |
> > +	git ls-files --stage -- "$@" | egrep -e '^160000 ' |
> 
> Nack.  egrep is not available on all platforms.  But then I have to wonder 
> why not saying "grep '^160000 '" instead?

Your last suggestion is easily and obviously better -- I'll assume you 
don't need an explicit patch and can just hand-edit mine.  Still, I'd have 
thought egrep was fine.  As far as I recall, it goes back to v7 Unix.  Or 
are there non-unix systems at issue (perhaps cygwin variants or something) 
that have grep but not egrep?

Anyway, thanks.

-- 
    Andy Dougherty		doughera@lafayette.edu

```

## Johannes Schindelin, 2007-12-18 14:01

Subject: Re: [PATCH] Minor portability patch to git-submodule
Message-ID: <Pine.LNX.4.64.0712181357150.23902@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0712181357150.23902%40racer.site
In-Reply-To: <Pine.LNX.4.64.0712180734520.28219@fractal.phys.lafayette.edu>

```
Hi,

On Tue, 18 Dec 2007, Andy Dougherty wrote:

> On Mon, 17 Dec 2007, Johannes Schindelin wrote:
> 
> > On Mon, 17 Dec 2007, Andy Dougherty wrote:
> > 
> > > -	git ls-files --stage -- "$@" | grep -e '^160000 ' |
> > > +	git ls-files --stage -- "$@" | egrep -e '^160000 ' |
> > 
> > Nack.  egrep is not available on all platforms.  But then I have to 
> > wonder why not saying "grep '^160000 '" instead?
> 
> Your last suggestion is easily and obviously better -- I'll assume you 
> don't need an explicit patch and can just hand-edit mine.  Still, I'd have 
> thought egrep was fine.  As far as I recall, it goes back to v7 Unix.

This is just another instance where we should look at existing systems 
and not so much at standards documents.

> Or are there non-unix systems at issue (perhaps cygwin variants or 
> something) that have grep but not egrep?

Well, I checked msysGit, and it has it.

That is, kind of: it is just a wrapper, calling "grep -E".  Which means 
yet another fork() on a fork() challenged platform, so I would appreciate 
it if we could avoid it.

Thanks,
Dscho

```
