[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
grep-2.5 problems with Solaris and with the GNU coding standards
From: |
Paul Eggert |
Subject: |
grep-2.5 problems with Solaris and with the GNU coding standards |
Date: |
Fri, 15 Mar 2002 05:38:00 -0800 (PST) |
> Date: Fri, 15 Mar 2002 03:11:27 -0500 (EST)
> From: "Steven M. Christensen" <address@hidden>
> when I run ./configure [on Solaris I] ... eventually get
> checking How to create links... ./configure: test: argument expected
> and then it stops.
There are two problems here. First, grep's configure uses "test -L"
and "test -e", which are not portable. But this stems from a
different problem. One of the last changes installed into grep 2.5
before it was released was this:
2002-03-13 Bernhard Rosenkraenzer <address@hidden>
* configure.in, src/Makefile.am: Don't duplicate code - make
egrep and fgrep links to grep and set matcher based on
application name, suggestion from
Guillaume Cottenceau <address@hidden>
But this change violates the GNU coding standards, as described in this
earlier ChangeLog entry:
1997-07-17 Alain Magloire <address@hidden>
* egrep, fgrep were links This is in violation of GNU
standards: "Please don't make the behavior of a
utility depend on the name used to invoke it. It is
useful sometimes to make a link to a utility with a
different name, and that should not change what it
does." For now egrep and fgrep will be copies of
grep. A better scheme should be found later. After
discussion with Tom Tromey <address@hidden>.
Here is a proposed patch.
2002-03-15 Paul Eggert <address@hidden>
Fix the following three problems:
. A porting problem with "test -L" and "test -e",
which do not work on some Solaris versions.
. The lack of conformance to the GNU coding standards noted in tne
1997-07-17 ChangeLog entry.
. The duplication of code noted in the 2002-03-13 ChangeLog entry.
by changing "egrep" and "fgrep" to be little shell scripts instead
of symbolic links. This is a tiny bit slower, but it fixes the bug.
People who want more speed should use "grep -E" and "grep -F".
* configure.in (SYMLINK, SYMLINKFROM): Remove. This code
wasn't portable, and is no longer needed now.
* src/Makefile.am (bin_SCRIPTS): New macro.
(egrep, fgrep): New rules.
Install egrep and fgrep as shell scripts, not as hard links.
* src/grep.c (main): The behavior should not depend on the
program name, to conform to the GNU coding standards.
===================================================================
RCS file: configure.in,v
retrieving revision 2.5
retrieving revision 2.5.0.1
diff -pu -r2.5 -r2.5.0.1
--- configure.in 2002/03/13 15:16:03 2.5
+++ configure.in 2002/03/15 13:10:52 2.5.0.1
@@ -141,28 +141,4 @@ if test x"$testpcre" = x"yes"; then
AC_CHECK_LIB(pcre, pcre_exec)
fi
-dnl Check how to create the {e,f}grep links
-AC_MSG_CHECKING([How to create links])
-rm -f test00 test01
-touch test00
-ln -s test00 test01 || :
-SYMLINK=""
-SYMLINKFROM="grep"
-if test -L test01; then
- SYMLINK="ln -s"
-else
- SYMLINKFROM="${bindir}/grep"
- rm -f test01
- ln test00 test01 || :
- if test -e test01; then
- SYMLINK="ln"
- else
- SYMLINK="cp"
- fi
-fi
-AC_MSG_RESULT($SYMLINK)
-AC_SUBST(SYMLINK)
-AC_SUBST(SYMLINKFROM)
-rm -f test00 test01
-
AC_OUTPUT(Makefile lib/Makefile lib/posix/Makefile src/Makefile tests/Makefile
po/Makefile.in intl/Makefile doc/Makefile m4/Makefile vms/Makefile
bootstrap/Makefile, [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in >
po/Makefile; echo timestamp > stamp-h])
===================================================================
RCS file: src/Makefile.am,v
retrieving revision 2.5
retrieving revision 2.5.0.1
diff -pu -r2.5 -r2.5.0.1
--- src/Makefile.am 2002/03/13 15:20:13 2.5
+++ src/Makefile.am 2002/03/15 13:13:05 2.5.0.1
@@ -4,6 +4,7 @@ AUTOMAKE_OPTIONS = ansi2knr no-dependenc
LN = ln
bin_PROGRAMS = grep
+bin_SCRIPTS = egrep fgrep
grep_SOURCES = grep.c dfa.c kwset.c search.c \
grepmat.c
noinst_HEADERS = grep.h dfa.h kwset.h getpagesize.h system.h
@@ -17,6 +18,12 @@ EXTRA_DIST = \
dosbuf.c \
vms_fab.c vms_fab.h
-install-exec-local:
- @SYMLINK@ @SYMLINKFROM@ $(bindir)/egrep
- @SYMLINK@ @SYMLINKFROM@ $(bindir)/fgrep
+egrep:
+ echo '#! /bin/sh' >$@
+ echo 'exec grep -E $${1+"$$@"}' >>$@
+ chmod a+x $@
+
+fgrep:
+ echo '#! /bin/sh' >$@
+ echo 'exec grep -F $${1+"$$@"}' >>$@
+ chmod a+x $@
===================================================================
RCS file: src/grep.c,v
retrieving revision 2.5
retrieving revision 2.5.0.1
diff -pu -r2.5 -r2.5.0.1
--- src/grep.c 2002/03/13 14:49:52 2.5
+++ src/grep.c 2002/03/15 13:22:36 2.5.0.1
@@ -1289,11 +1289,6 @@ main (int argc, char **argv)
if (program_name && strrchr (program_name, '/'))
program_name = strrchr (program_name, '/') + 1;
- if (!strcmp(program_name, "egrep"))
- setmatcher ("egrep");
- if (!strcmp(program_name, "fgrep"))
- setmatcher ("fgrep");
-
#if defined(__MSDOS__) || defined(_WIN32)
/* DOS and MS-Windows use backslashes as directory separators, and usually
have an .exe suffix. They also have case-insensitive filesystems. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- grep-2.5 problems with Solaris and with the GNU coding standards,
Paul Eggert <=