Norihiro Tanaka wrote:
Fail in reversed-range-endpoints test after egrep and fgrep go back to shell scripts. I seem that the program name doesn't remove correctly.
Thanks, I fixed that in a different way, with the attached patch.
From 37e608f8cab613a178764e5847d5f035cb657cb6 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Wed, 26 Mar 2014 21:30:26 -0700 Subject: [PATCH] egrep, fgrep: improve diagnostics from shell scripts This should fix Bug#17098. * src/Makefile.am (EXTRA_DIST): Add egrep.sh. (egrep fgrep): Depend on egrep.sh and Makefile. Build from new file egrep.sh, as this makes the build process easier to follow. Arrange for $0 to look nicer in subgrep. * src/egrep.sh: New file. --- src/Makefile.am | 15 +++++---------- src/egrep.sh | 10 ++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 src/egrep.sh diff --git a/src/Makefile.am b/src/Makefile.am index 2b5a365..27a2bc3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -42,19 +42,14 @@ grep_LDADD = $(LDADD) $(LIB_PCRE) localedir = $(datadir)/locale AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib -EXTRA_DIST = dosbuf.c +EXTRA_DIST = dosbuf.c egrep.sh -egrep fgrep: +egrep fgrep: egrep.sh Makefile $(AM_V_GEN)grep=`echo grep | sed -e '$(transform)'` && \ case $@ in egrep) option=-E;; fgrep) option=-F;; esac && \ - (echo '#!$(SHELL)' && \ - echo 'grep=grep' && \ - echo 'case $$0 in */*)' && \ - echo ' g=$${0%/*}/'"'$$grep'" && \ - echo ' test -x "$$g" && grep=$$g' && \ - echo 'esac' && \ - echo 'exec "$$grep" '"$$option"' "$$@"' \ - ) >$@-t + sed -e 's|[@]SHELL@|$(SHELL)|g' \ + -e "s|[@]grep@|$$grep|g" \ + -e "s|[@]option@|$$option|g" <egrep.sh >$@-t $(AM_V_at)chmod +x $@-t $(AM_V_at)mv $@-t $@ diff --git a/src/egrep.sh b/src/egrep.sh new file mode 100644 index 0000000..f1b4146 --- /dev/null +++ b/src/egrep.sh @@ -0,0 +1,10 @@ +#!@SHELL@ +grep=grep +case $0 in + */*) + if test -x "${0%/*}/@grep@"; then + PATH=${0%/*}:$PATH + grep=@grep@ + fi;; +esac +exec $grep @option@ "$@" -- 1.8.5.3
