Hi Tormen,

Tormen wrote:

>     sed -e 1$'{w/dev/stdout\n;d}' -i /tmp/x
>
> in a dash script will yield the error message:
>
>     sed: -e expression #1, char 2: unknown command: `$'
>
> But why ? :(

POSIX sayeth[1]:

  The '$' character is used to introduce parameter expansion, command
  substitution, or arithmetic evaluation. If an unquoted '$' is
  followed by a character that is not one of the following:

  * A numeric character
  * The name of one of the special parameters (see 2.5.2 Special
    Parameters)
  * A valid first character of a variable name
  * A <left-curly-bracket> ( '{' )
  * A <left-parenthesis>

  the result is unspecified.

A single-quote is not the name of a special parameter nor valid as the
first character of a variable name, so this is unspecified behavior
and should be avoided in scripts meant to run on an arbitrary POSIX
shell.

However the next major version of POSIX is likely to mandate support
for $'' string handling[2].  Work towards an implementation in dash would
be very welcome.

Thanks and hope that helps,
Jonathan

[1] 
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06
[2] http://austingroupbugs.net/view.php?id=249
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to