From: Jonathan Nieder <jrnieder@gmail.com>
To: Tormen <quickhelp@gmail.com>
Cc: dash@vger.kernel.org
Subject: Re: sed script fails to run in dash
Date: Fri, 22 Nov 2013 11:25:59 -0800 [thread overview]
Message-ID: <20131122192559.GH4212@google.com> (raw)
In-Reply-To: <528F9E5E.4020807@gmail.com>
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
next prev parent reply other threads:[~2013-11-22 19:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-22 18:11 sed script fails to run in dash Tormen
2013-11-22 19:20 ` Seb
2013-11-22 19:25 ` Jonathan Nieder [this message]
2013-11-22 19:26 ` Eric Blake
2013-11-23 0:14 ` Tormen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131122192559.GH4212@google.com \
--to=jrnieder@gmail.com \
--cc=dash@vger.kernel.org \
--cc=quickhelp@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox