Nick Bowler wrote:
> > Note: I think POSIX [1] mandates the behaviour of OpenBSD and Solaris sed.
> > But that is not immediately relevant for the Autoconf manual: The
> > portability
> > problem exists regardless of how we might interpret POSIX.
>
> The GNU behaviour is likely non-conforming with Issue 5 (1997) and
> earlier specifications, but since Issue 6 (2001) the meaning of \n in
> the replacement string is explicitly unspecified. So both behaviours
> are POSIX-compliant nowadays.
After reading the POSIX spec again, I tend to agree (although there's still
some ambiguity).
> > +In the replacement text of an @samp{s}, it is not portable to use
> > +escape sequences like @samp{\n}. While GNU @command{sed} interprets
> > +them, the @command{sed} commands of OpenBSD and Solaris don't.
>
> It would probably be helpful to mention that the POSIX-standard and
> portable method to substitute a newline with sed is to use backslash-
> newline. For example:
>
> % echo foo | sed 's/f.*/line1\
> line2/'
> line1
> line2
That's correct. For newlines, this seems to be portable nowadays.
Bruno