GNU bug report logs -
#20883
egrep on Solaris fails to call original grep binary
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Fri, 26 Jun 2015 13:40:03 -0700
with message-id <558DB8A3.5040209 <at> cs.ucla.edu>
and subject line Re: bug#20883: egrep on Solaris fails to call original grep binary
has caused the debbugs.gnu.org bug report #20883,
regarding egrep on Solaris fails to call original grep binary
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
20883: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20883
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
Hi,
$ PATH=/usr/bin gegrep
grep: illegal option -- E
Usage: grep [-c|-l|-q] -bhinsvw pattern file . . .
The gegrep script:
#!/bin/bash
grep=grep
case $0 in
*/*)
dir=${0%/*}
if test -x "$dir/grep"; then
PATH=$dir:$PATH
grep=grep
fi;;
esac
exec $grep -E "$@"
The problem is that in the case when egrep is called without specifying full
path (there's no '/' in $0), it calls the grep binary (with -E option) in
default PATH. In the case of Solaris /usr/bin/grep is not a GNU grep, thus
error message about missing -E option.
I can see two possibilities of fixing it
a) As the GNU grep is called 'ggrep' on Solaris, we should use
grep=ggrep
and all is good. No need to change anything in GNU grep, just keep our
local Solaris patch.
b) As the GNU grep is available on /usr/gnu/bin path too (users who
deserve to have GNU commandline behavior use /usr/gnu/bin before
/usr/bin in PATH), we should use the /usr/gnu/bin prefix path for grep:
--- grep-2.20/src/egrep.sh 2015-06-23 14:03:57.123888876 +0200
+++ grep-2.20/src/egrep.sh 2015-06-23 14:03:27.529153050 +0200
@@ -7,5 +7,8 @@ case $0 in
PATH=$dir:$PATH
grep=@grep@
fi;;
+ *)
+ PATH="@prefix@/bin:$PATH"
+ ;;
esac
exec $grep @option@ "$@"
--- grep-2.20/src/Makefile.am 2015-06-23 07:17:45.984838354 -0700
+++ grep-2.20/src/Makefile.am 2015-06-23 07:17:45.052710962 -0700
@@ -56,6 +56,7 @@ egrep fgrep: egrep.sh Makefile
sed -e 's|[@]SHELL@|$(SHELL)|g' \
-e "$$edit_substring" \
-e "s|[@]grep@|$$grep|g" \
+ -e "s|[@]prefix@|$(prefix)|g" \
-e "s|[@]option@|$$option|g" <$(srcdir)/egrep.sh >$@-t
$(AM_V_at)chmod +x $@-t
$(AM_V_at)mv $@-t $@
Generally I do believe that a) is easier and less risky change, but b)
feels to be more generic fix. (User may have GNU grep installed in /tmp
in which case /tmp/bin/egrep won't work unless you have /tmp/bin in your
PATH).
Comments welcome :)
Thank you
--
Vlad
[Message part 3 (message/rfc822, inline)]
Thanks for following up; sounds like grep is OK then, so closing the bug.
This bug report was last modified 9 years and 334 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.