bug-texinfo
[Top][All Lists]
Advanced

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

GNU texinfo 4.2 and egrep/fgrep


From: Paul Eggert
Subject: GNU texinfo 4.2 and egrep/fgrep
Date: Fri, 31 May 2002 21:42:45 -0700 (PDT)

I've been porting GNU tools to a stricter POSIX 1003.1-2001
environment, and noticed that Texinfo uses the obsolecent commands
'egrep' and 'fgrep'.  POSIX no longer requires these commands; you're
supposed to use grep -E and grep -F instead.

Here is a proposed patch.

2002-05-31  Paul Eggert  <address@hidden>

        Don't assume that egrep and fgrep exist.  POSIX 1003.1-2001 no
        longer requires them; you're supposed to use grep -E and grep -F
        instead.  Use grep -E and grep -F if available, falling
        back on egrep and fgrep on traditional hosts.  Or use plain
        grep if it makes no difference.

        * tests/cond (EGREP): New var; use it instead of egrep.
        Use grep instead of fgrep, adjusting patterns accordingly.
        * util/gen-dir-node (infofiles): Use 'sed' instead of egrep.
        (filesectdata): Use grep instead of fgrep.
        * util/texi2dvi (language, finished): Likewise.
        (command_line_filename): Use shell pattern insteaad of egrep.

diff -pru texinfo/makeinfo/tests/cond texinfo-posix/makeinfo/tests/cond
--- texinfo/makeinfo/tests/cond 2000-12-22 07:02:32.000000000 -0800
+++ texinfo-posix/makeinfo/tests/cond   2002-05-31 21:24:38.135809000 -0700
@@ -3,30 +3,36 @@
 
 : ${srcdir=.}
 
+if echo a | grep -E '(a|b)' >/dev/null 2>&1; then
+   EGREP='grep -E'
+else
+   EGREP='egrep'
+fi
+
 # Default Info output.
 ../makeinfo -o cond.out $srcdir/cond.txi || exit 1
-egrep 'This is (ifnothtml|ifinfo|ifnottex) text' cond.out >/dev/null \
+$EGREP 'This is (ifnothtml|ifinfo|ifnottex) text' cond.out >/dev/null \
   || exit 2
-test `fgrep ' text.' cond.out | wc -l` -eq 3 || exit 3
+test `grep ' text\.' cond.out | wc -l` -eq 3 || exit 3
 
 # Default HTML output.
 ../makeinfo --no-split --html -o cond.out $srcdir/cond.txi || exit 1
-egrep 'This is (html|ifhtml|ifnotinfo|ifnottex) text' cond.out >/dev/null \
+$EGREP 'This is (html|ifhtml|ifnotinfo|ifnottex) text' cond.out >/dev/null \
  || exit 2
-test `fgrep ' text.' cond.out | wc -l` -eq 4 || exit 3
+test `grep ' text\.' cond.out | wc -l` -eq 4 || exit 3
 
 # --ifhtml off, --ifinfo off, --iftex off.
 ../makeinfo --no-ifhtml --no-ifinfo --no-iftex -o cond.out $srcdir/cond.txi || 
exit 1
-egrep 'This is ifnot(html|info|tex) text' cond.out >/dev/null \
+$EGREP 'This is ifnot(html|info|tex) text' cond.out >/dev/null \
  || exit 2
-test `fgrep ' text.' cond.out | wc -l` -eq 3 || exit 3
+test `grep ' text\.' cond.out | wc -l` -eq 3 || exit 3
 
 # Do we really need to test all the other permutations?
 
 # --ifhtml on, --ifinfo on, --iftex on.
 ../makeinfo --ifhtml --ifinfo --iftex -o cond.out $srcdir/cond.txi || exit 1
-egrep 'This is (html|ifhtml|ifinfo|tex|iftex) text' cond.out >/dev/null \
+$EGREP 'This is (html|ifhtml|ifinfo|tex|iftex) text' cond.out >/dev/null \
  || exit 2
-test `fgrep ' text.' cond.out | wc -l` -eq 5 || exit 3
+test `grep ' text\.' cond.out | wc -l` -eq 5 || exit 3
 
 rm -f cond.out cond.info
diff -pru texinfo/util/gen-dir-node texinfo-posix/util/gen-dir-node
--- texinfo/util/gen-dir-node   1998-08-11 14:41:15.000000000 -0700
+++ texinfo-posix/util/gen-dir-node     2002-05-31 00:20:33.478225000 -0700
@@ -79,7 +79,7 @@ moobler
 ### then generate entries for those in the same way, putting the info for 
 ### those at the end....
 
-infofiles=`(cd ${INFODIR}; /bin/ls | grep -v '\-[0-9]*$' | egrep -v 
'^dir$|^dir\.info$|^dir\.orig$')`
+infofiles=`(cd ${INFODIR}; /bin/ls | sed '/-[0-9]*$/d; /^dir$/d; 
/^dir\.info$/d; /^dir\.orig$/d')`
 
 # echoing gets clobbered by backquotes; we do it the hard way...
 lines=`wc $SKELETON | awk '{print $1}'`
@@ -167,8 +167,8 @@ fi
 
 # Sort remaining files by INFO-DIR-SECTION.
 prevsect=
-filesectdata=`(cd ${INFODIR}; fgrep INFO-DIR-SECTION /dev/null ${infofiles} | \
-             fgrep -v 'INFO-DIR-SECTION Miscellaneous' | \
+filesectdata=`(cd ${INFODIR}; grep INFO-DIR-SECTION /dev/null ${infofiles} | \
+             grep -v 'INFO-DIR-SECTION Miscellaneous' | \
              sort -t: -k2 -k1 | tr ' ' '_')`
 for sectdata in ${filesectdata}; do
   file=`echo ${sectdata} | cut -d: -f1`
diff -pru texinfo/util/texi2dvi texinfo-posix/util/texi2dvi
--- texinfo/util/texi2dvi       2002-04-01 06:20:59.000000000 -0800
+++ texinfo-posix/util/texi2dvi 2002-05-31 00:25:46.016019000 -0700
@@ -305,8 +305,10 @@ for command_line_filename in ${1+"$@"}; 
 
   # If the COMMAND_LINE_FILENAME is not absolute (e.g., --debug.tex),
   # prepend `./' in order to avoid that the tools take it as an option.
-  echo "$command_line_filename" | egrep '^(/|[A-z]:/)' >/dev/null \
-  || command_line_filename="./$command_line_filename"
+  case $command_line_filename in
+    /* | [A-z]:/*) ;;
+    *) command_line_filename="./$command_line_filename";;
+  esac
 
   # See if the file exists.  If it doesn't we're in trouble since, even
   # though the user may be able to reenter a valid filename at the tex
@@ -361,7 +363,7 @@ for command_line_filename in ${1+"$@"}; 
   # Otherwise, guess from the file extension.
   if test -n "$set_language"; then
     language=$set_language
-  elif sed 1q "$command_line_filename" | fgrep 'input texinfo' >/dev/null; then
+  elif sed 1q "$command_line_filename" | grep 'input texinfo' >/dev/null; then
     language=texinfo
   else
     language=
@@ -540,7 +542,7 @@ for command_line_filename in ${1+"$@"}; 
     # subdirs, since texi2dvi does not try to compare xref files in
     # subdirs.  Performing xref files test is still good since LaTeX
     # does not report changes in xref files.
-    if fgrep "Rerun to get" "$filename_noext.log" >/dev/null 2>&1; then
+    if grep "Rerun to get" "$filename_noext.log" >/dev/null 2>&1; then
       finished=
     fi
 



reply via email to

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