Re: sed script fails to run in dash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le Fri, 22 Nov 2013 19:11:42 +0100
Tormen a écrit:

Hello,


> but also just this line:
> 
>     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 ? :(

It seems dash strictly passes what you have given and which is
sed-speaking incorrect:

$ dash -c "strace sed -e 1$'{w/dev/stdout\n;d}' -i /tmp/x"
execve("/usr/bin/sed", ["sed", "-e", "1${w/dev/stdout\\n;d}", ...
                                      ^^^
Bash does not, and so passes something sed understands:

$ bash -c "strace sed -e 1$'{w/dev/stdout\n;d}' -i /tmp/x"
execve("/usr/bin/sed", ["sed", "-e", "1{w/dev/stdout \n;d}", ...
                                      ^^^
If you escape the "$" with bash, you will get your kitten back:

$ bash -c "sed -e 1\\$'{w/dev/stdout\n;d}' -i /tmp/x"
sed: -e expression #1, char 2: unknown command: `$'


Take care,
Seb.
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux