autoconf-patches
[Top][All Lists]
Advanced

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

Re: Detecting GNU sed


From: Pavel Roskin
Subject: Re: Detecting GNU sed
Date: Tue, 31 Oct 2000 10:35:54 -0500 (EST)

Hello, Alexandre!

> > +(echo 'xyz-xY' | $sed 's/\bx.\b/XY/' | grep 'xyz-XY') >/dev/null 2>&1 ||
> 
> Use test "x`echo ... | $sed ...`" = "x..." instead.  Other than that,
> ok.

Search for the word "avoidable" in the documentation. It is exactly about
what you are suggesting. Besides, I never feel confident about trailing
newlines, especially on systems using CR/LF.

The documentation suggests using "case", and this is what's used for m4
few lines above in autoupdate.sh. I'm not sure about need for the leading
"x" but I added it just in case.

I hope you will choose my new variant, but I'm posting both. Both work for
me on RedHat Linux 6.2 with bash-1.14.7.

Variant 1
====================================
Index: autoupdate.sh
--- autoupdate.sh       Fri Oct 27 09:48:15 2000
+++ autoupdate.sh       Tue Oct 31 10:20:57 2000
@@ -88,7 +88,7 @@
 # If we don't have GNU Sed, exit 77 so that the test suite just skip
 # this test.
 sed=${SED-sed}
-$sed --version </dev/null >/dev/null 2>&1 ||
+test "x`echo 'xyz-xY' | $sed 's/\bx.\b/XY/' 2>/dev/null`" = "xxyz-XY" ||
   { echo autoupdate requires GNU sed >&2; exit 77; }
 
 # Variables.
====================================

Variant 2
====================================
Index: autoupdate.sh
--- autoupdate.sh       Fri Oct 27 09:48:15 2000
+++ autoupdate.sh       Tue Oct 31 10:24:55 2000
@@ -88,8 +88,10 @@
 # If we don't have GNU Sed, exit 77 so that the test suite just skip
 # this test.
 sed=${SED-sed}
-$sed --version </dev/null >/dev/null 2>&1 ||
-  { echo autoupdate requires GNU sed >&2; exit 77; }
+case x`echo 'xyz-xY' | $sed 's/\bx.\b/XY/' 2>/dev/null` in
+  xxyz-XY*);;
+  *) echo autoupdate requires GNU sed >&2; exit 77 ;;
+esac
 
 # Variables.
 : address@hidden@}}
====================================

ChangeLog is the same. "exit 77" is not in parentheses because trap is not
installed yet.

Regards,
Pavel Roskin




reply via email to

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