]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Further clarification on sed -e portability.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Tue, 22 Jun 2010 05:29:35 +0000 (07:29 +0200)
committerEric Blake <eblake@redhat.com>
Wed, 23 Jun 2010 03:31:39 +0000 (21:31 -0600)
See also http://austingroupbugs.net/view.php?id=262 and
http://austingroupbugs.net/view.php?id=264.

* doc/autoconf.texi (Limitations of Usual Tools) <sed>: Clarify
more about sed -e and Posix limitations.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
doc/autoconf.texi

index 024a83559e5b61bac49877cbe5f0236689a29415..c589cce795564ccdc777ffec1d0c4597965c99be 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-06-22  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+       and Eric Blake  <eblake@redhat.com>
+
+       Further clarification on sed -e portability.
+       * doc/autoconf.texi (Limitations of Usual Tools) <sed>: Clarify
+       more about sed -e and Posix limitations.
+
 2010-06-22  Bruno Haible  <bruno@clisp.org>
 
        Document how to use literal newlines in makefile rules.
index 10609554ea00254021d76fec14aa149061b3e5b8..35c40c898dac99554575ce3a39fabc3ac5fff1dc 100644 (file)
@@ -18253,13 +18253,14 @@ but Posix says that this use of a semicolon has undefined effect if
 should use semicolon only with simple scripts that do not use these
 verbs.
 
-The argument of the @option{-e} option must be a syntactically complete
-script.  GNU @command{sed} allows to pass multiple script fragments,
-each as argument of a separate @option{-e} option, that are then combined,
-with newlines between the fragments.  A future Posix revision may allow
-this as well.  But in Posix:2008, this is not allowed, and the
-@command{sed} programs on Solaris 10, HP-UX 11, and AIX don't allow it
-either:
+Posix up to the 2008 revision requires the argument of the @option{-e}
+option to be a syntactically complete script.  GNU @command{sed} allows
+to pass multiple script fragments, each as argument of a separate
+@option{-e} option, that are then combined, with newlines between the
+fragments, and a future Posix revision may allow this as well.  This
+approach is not portable with script fragments ending in backslash; for
+example, the @command{sed} programs on Solaris 10, HP-UX 11, and AIX
+don't allow splitting in this case:
 
 @example
 $ @kbd{echo a | sed -n -e 'i\}
@@ -18269,11 +18270,23 @@ $ @kbd{echo a | sed -n -e 'i\' -e 0}
 Unrecognized command: 0
 @end example
 
-Commands inside @{ @} brackets are further restricted.  Posix says that
+@noindent
+In practice, however, this technique of joining fragments
+through @option{-e} works for multiple @command{sed} functions within
+@samp{@{} and @samp{@}}, even if that is not specified by Posix:
+
+@example
+@c The quote around the closing brace silences interactive zsh.
+$ @kbd{echo a | sed -n -e '/a/@{' -e s/a/b/ -e p -e '@}'}
+b
+@end example
+
+Commands inside @{ @} brackets are further restricted.  Posix 2008 says that
 they cannot be preceded by addresses, @samp{!}, or @samp{;}, and that
 each command must be followed immediately by a newline, without any
 intervening blanks or semicolons.  The closing bracket must be alone on
-a line, other than white space preceding or following it.
+a line, other than white space preceding or following it.  However, a
+future version of Posix may standardize the use of addresses within brackets.
 
 Contrary to yet another urban legend, you may portably use @samp{&} in
 the replacement part of the @code{s} command to mean ``what was