[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20883: egrep on Solaris fails to call original grep binary
From: |
Vladimir Marek |
Subject: |
bug#20883: egrep on Solaris fails to call original grep binary |
Date: |
Tue, 23 Jun 2015 17:39:15 +0200 |
User-agent: |
Mutt/1.5.22.1-rc1 (2013-10-16) |
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
address@hidden@
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|address@hidden@|$(SHELL)|g' \
-e "$$edit_substring" \
-e "s|address@hidden@|$$grep|g" \
+ -e "s|address@hidden@|$(prefix)|g" \
-e "s|address@hidden@|$$option|g" <$(srcdir)/egrep.sh >address@hidden
$(AM_V_at)chmod +x address@hidden
$(AM_V_at)mv address@hidden $@
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
- bug#20883: egrep on Solaris fails to call original grep binary,
Vladimir Marek <=