grep-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Grep-devel] /bin/sh: /src/grep: No such file or directory


From: Jim Meyering
Subject: [Grep-devel] /bin/sh: /src/grep: No such file or directory
Date: Mon, 18 Feb 2019 11:10:43 -0800

I was dismayed to see some of these when building grep:

  /bin/sh: /src/grep: No such file or directory

I propose to fix it with the following (bearing in mind my
requirement that we use just-built tools as much as possible,
to increase coverage). Suggestions for improvement welcome.

>From abd91d89d72cbbe7b8d41340b94ec4c0d721d255 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 18 Feb 2019 10:42:24 -0800
Subject: [PATCH] maint: accommodate GREP/EGREP usage inherited from gnulib

maint.mk used to use "grep". Now it uses $GREP. That exposes
a latent problem, causing "make" to emit diagnostics like this:
  /bin/sh: /src/grep: No such file or directory
Here, we'll set EGREP and GREP to wrapper scripts that use
the tool in src/ when it exists, yet fall back to whatever
configure found otherwise.
* configure.ac: Create the wrapper scripts we'll tell make to
use for grep and egrep.
(GREP, EGREP): Point to each just-created script.
* Makefile.am (DISTCLEANFILES): Define, so that these configure-
generated files are deleted.
---
 Makefile.am  |  2 ++
 configure.ac | 34 ++++++++++++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 5d398e4..0bd50d1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -69,6 +69,8 @@ ASSORT = LC_ALL=C sort
 # Extract all lines up to the first one starting with "##".
 prologue = perl -ne '/^\#\#/ and exit; print' $(srcdir)/THANKS.in

+DISTCLEANFILES = prefer-this-egrep prefer-this-grep
+
 THANKS: THANKS.in Makefile.am .mailmap thanks-gen
        $(AM_V_GEN)rm -f address@hidden $@;                                     
\
        {                                                               \
diff --git a/configure.ac b/configure.ac
index 4999840..6cbf55e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,9 @@ fn_grep () {
   return $rc
 }

+prev_grep=${GREP:-grep}
+prev_egrep=${EGREP:-grep -E}
+
 test -n "$GREP" || GREP=fn_grep
 test -n "$EGREP" || EGREP=fn_grep
 ac_cv_path_EGREP=$EGREP
@@ -218,6 +221,35 @@ esac
 COLORIZE_SOURCE=colorize-$suffix.c
 AC_SUBST([COLORIZE_SOURCE])

+rm -f prefer-this-grep
+sed 's!PWD!'"$PWD"'!g;s!GREP!'"$prev_grep"'!g' <<'EOF' \
+  > prefer-this-grep && chmod a+x-w prefer-this-grep
+#!/bin/sh
+if test -x 'PWD/src/grep'; then
+  PATH="PWD/src:$PATH"
+  export PATH
+  exec grep "$@"
+fi
+exec 'GREP' "$@"
+EOF
+
+rm -f prefer-this-egrep
+sed 's!PWD!'"$PWD"'!g;s!EGREP!'"$prev_egrep"'!g' <<'EOF' \
+  > prefer-this-egrep && chmod a+x-w prefer-this-egrep
+#!/bin/sh
+if test -x 'PWD/src/grep'; then
+  PATH="PWD/src:$PATH"
+  export PATH
+  exec grep -E "$@"
+fi
+exec 'EGREP' "$@"
+EOF
+
+# Tell Makefiles etc. to use src/grep if it exists, but fall back
+# to using the configure-chosen value or searching the path.
+GREP="$PWD/prefer-this-grep"
+EGREP="$PWD/prefer-this-egrep"
+
 AC_CONFIG_FILES([
   Makefile
   lib/Makefile
@@ -227,6 +259,4 @@ AC_CONFIG_FILES([
   doc/Makefile
   gnulib-tests/Makefile
 ])
-GREP="$ac_abs_top_builddir/src/grep"
-EGREP="$ac_abs_top_builddir/src/grep -E"
 AC_OUTPUT
--
2.21.0.rc1.9.gca1b411648



reply via email to

[Prev in Thread] Current Thread [Next in Thread]