20571824 gegrep fails unless /usr/gnu/bin is in PATH
authorVladimir Marek <Vladimir.Marek@oracle.com>
Fri, 26 Jun 2015 13:22:26 +0200
changeset 4574 7ddafe81d631
parent 4573 64ad0d7d3334
child 4575 bd0427b0c2c0
20571824 gegrep fails unless /usr/gnu/bin is in PATH
components/ggrep/patches/correct_prefix.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ggrep/patches/correct_prefix.patch	Fri Jun 26 13:22:26 2015 +0200
@@ -0,0 +1,45 @@
+This patch was created inhouse and is not applicable for submitting to
+upstream. This is because it implements Solaris oddity - having the binaries
+available both without prefix and with 'g' prefix at the same time, only in
+different paths.
+
+--- grep-2.20/src/egrep.sh	2015-06-29 16:48:08.536062429 +0200
++++ grep-2.20/src/egrep.sh	2015-06-29 16:47:57.380731794 +0200
[email protected]@ -1,11 +1,29 @@
+ #[email protected]@
+-grep=grep
+-case $0 in
++# The script is a wrapper to GNU grep to be called with apropriate (-E or -F)
++# command line option. We can't just run 'ggrep' as the path may not contain
++# '/usr/bin' and we can't just use 'grep' as the PATH may not contain
++# '/usr/gnu/bin'. Also we can't just use fixed path as /usr/gnu/bin/grep because
++# this script must work even from workspace before being installed into /usr/...
++# testing the binaries from the workspace.
++
++if [[ "$( /usr/bin/basename "$0" )" == g* ]]; then
++  # gfgrep or gegrep (potentially in /usr/bin)
++  grep=ggrep
++else
++  # fgrep or egrep in (potentially in /usr/gnu/bin)
++  grep=grep
++fi
++
++case "$0" in
+   */*)
+-    dir=${0%/*}
+-    if test -x "$dir/@[email protected]"; then
+-      PATH=$dir:$PATH
+-      [email protected]@
+-    fi;;
++    dir="${0%/*}"
++    if test -x "$dir/$grep"; then
++      PATH="$dir:$PATH"
++    fi
++    ;;
++  *)
++    PATH="@[email protected]/bin:$PATH"
++    ;;
+ esac
+-exec $grep @[email protected] "[email protected]"
++
++exec "$grep" @[email protected] "[email protected]"