[Top][All Lists]

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

Re: sed portability

From: Paul Eggert
Subject: Re: sed portability
Date: Mon, 03 Jan 2005 00:33:33 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Ralf Wildenhues <address@hidden> writes:

> | @example
> | sed -e @var{instruction-1} \
> |     -e @var{instruction-2}
> | @end example
> is not equivalent to
> | @example
> | sed @var{instruction-1};@var{instruction-2}
> | @end example
> everywhere.

Thanks for reporting that.  I installed this fix:

2005-01-03  Paul Eggert  <address@hidden>

        * doc/autoconf.texi (Limitations of Usual Tools): Warn about
        sed 'command1;command2'.  Problem reported by Ralf Wildenhues.

Index: autoconf.texi
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.859
retrieving revision 1.860
diff -p -u -r1.859 -r1.860
--- autoconf.texi       3 Jan 2005 07:35:21 -0000       1.859
+++ autoconf.texi       3 Jan 2005 08:31:44 -0000       1.860
@@ -11799,23 +11799,37 @@ Nested parenthesization in patterns (e.g
 quite portable to modern hosts, but is not supported by some older
 @command{sed} implementations like SVR3.
-Of course the option @option{-e} is portable, but it is not needed.  No
-valid Sed program can start with a dash, so it does not help
-disambiguating.  Its sole usefulness is to help enforcing indentation as
+The @option{-e} option is portable.
+Some people prefer to use it:
-sed -e @var{instruction-1} \
-    -e @var{instruction-2}
+sed -e '@var{command-1}' \
+    -e '@var{command-2}'
 @end example
-as opposed to
+as opposed to the equivalent:
-sed @var{instruction-1};@var{instruction-2}
+sed '
+  @var{command-1}
+  @var{command-2}
 @end example
+The following usage is sometimes equivalent:
+sed '@var{command-1};@var{command-2}'
address@hidden example
+but Posix says that this use of a semicolon has undefined effect if
address@hidden's verb is @address@hidden, @samp{a}, @samp{b}, @samp{c},
address@hidden, @samp{r}, @samp{t}, @samp{w}, @samp{:}, or @samp{#}, so you
+should use semicolon only with simple scripts that do not use these
 Contrary to yet another urban legend, you may portably use @samp{&} in
 the replacement part of the @code{s} command to mean ``what was
 matched''.  All descendants of Unix version 7 @command{sed}

reply via email to

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