Re: sed portability

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

 



Ralf Wildenhues <Ralf.Wildenhues@xxxxxx> 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  <eggert@xxxxxxxxxxx>

	* 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
-in:
+The @option{-e} option is portable.
+Some people prefer to use it:
 
 @example
-sed -e @var{instruction-1} \
-    -e @var{instruction-2}
+sed -e '@var{command-1}' \
+    -e '@var{command-2}'
 @end example
 
 @noindent
-as opposed to
+as opposed to the equivalent:
 
 @example
-sed @var{instruction-1};@var{instruction-2}
+sed '
+  @var{command-1}
+  @var{command-2}
+'
 @end example
 
+@noindent
+The following usage is sometimes equivalent:
+
+@example
+sed '@var{command-1};@var{command-2}'
+@end example
+
+but Posix says that this use of a semicolon has undefined effect if
+@var{command-1}'s verb is @samp{@{}, @samp{a}, @samp{b}, @samp{c},
+@samp{i}, @samp{r}, @samp{t}, @samp{w}, @samp{:}, or @samp{#}, so you
+should use semicolon only with simple scripts that do not use these
+verbs.
+
 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}


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux