On Wed, Oct 22, 2014 at 8:37 AM, Christopher Zimmermann
<chr...@openbsd.org> wrote:
> $ sed -e "{ y/o/u/ }"
> sed: 1: "{ y/o/u/ }": extra text at the end of a transform command
>
> but this is allowed according to the manual:
>
>      Functions can be combined to form a function list, a list of sed
>      functions separated by newlines, as follows:
>
>            { function
>              function
>              ...
>              function
>            }
>
>      The `{' can be preceded or followed by whitespace.  The function can be
>      preceded by whitespace as well.  The terminating `}' must be preceded by
>      a newline or optional whitespace.

That looks like a documentation bug to me.  To quote the POSIX spec:
----------
[2addr] {editing command
editing command
...
} Execute a list of sed editing commands only when the pattern space
is selected. The

                  list of sed editing commands shall be surrounded by
braces and separated by
                  <newline> characters, and conform to the following
rules. The braces can be
                  preceded or followed by <blank> characters. The
editing commands can be
                  preceded by <blank> characters, but shall not be
followed by <blank> characters.
                  The <right-brace> shall be preceded by a <newline>
and can be preceded or
                  followed by <blank> characters.
----------

So the newline before the close-brace is required.  Since the code
matches the spec, I think we should change the doc to match both of
them.  Or is there some reason this extension is required?


Philip Guenther

Reply via email to