Subject: Re: bug#19998: GREP_OPTIONS alternative?

From: Santiago Ruano Rincón <[email-masked]>
Date: Thu, 12 Mar 2015 09:04:56 +0100

Hi,

El 11/03/15 a las 17:58, Paul Eggert escribió:
... 
> On the other hand, now that I've tested it, I see that when I type 'fgrep'
> Bash invokes it as '/bin/fgrep', which surprises me and which defeats the
> purpose of having 'fgrep' look at $0.  I installed the attached patch, which
> should fix that.
...

Then, please consider the attached patch, to clean src/Makefile.am up.

This shouldn't belong to this topic, but is there any reason to call
this wrapper with a shell other than sh (I've set it to /bin/sh in
Debian)

Cheers,

Santiago
diff --git a/src/Makefile.am b/src/Makefile.am
index 5c608df..81a5027 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,15 +47,7 @@ EXTRA_DIST = dosbuf.c egrep.sh
 egrep fgrep: egrep.sh Makefile
 	$(AM_V_GEN)grep=`echo grep | sed -e '$(transform)'` &&		\
 	case $@ in egrep) option=-E;; fgrep) option=-F;; esac &&	\
-	shell_does_substrings='set x/y && d=$${1%/*} && test "$$d" = x' && \
-	if $(SHELL) -c "$$shell_does_substrings" 2>/dev/null; then	\
-	  edit_substring='s,X,X,';					\
-	else								\
-	  edit_substring='s,\$${0%/\*},`expr "X$$0" : '\''X\\(.*\\)/'\''`,g'; \
-	fi &&								\
 	sed -e 's|[@]SHELL@|$(SHELL)|g'					\
-	    -e "$$edit_substring"					\
-	    -e "s|[@]grep@|$$grep|g"					\
 	    -e "s|[@]option@|$$option|g" <$(srcdir)/egrep.sh >$@-t
 	$(AM_V_at)chmod +x $@-t
 	$(AM_V_at)mv $@-t $@