[Top][All Lists]

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

Re: how does escaping in "`...`" work?

From: Matthew Woehlke
Subject: Re: how does escaping in "`...`" work?
Date: Mon, 07 Jun 2010 18:49:48 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20090825 Fedora/ Thunderbird/ Mnenhy/

Eric Blake wrote:
On 06/07/2010 04:47 PM, Matthew Woehlke wrote:
But this does not:
$ echo "`echo \"you don\'t   say\"`"
you don\'t   say

\' is not special inside ``.  If it is not special, then the \ is
preserved on to the nested command.  Bash's behavior matches POSIX here.

Right; w.r.t. the ``'s, I didn't expect it was. The confusion was due to not understanding if the \' is or is not inside a ""'d string in the command substitution.

I expected:
"you don't say"

Then don't use \'.  echo "`echo \"you don't  say\"`"

I think you meant:
echo "`echo \\\"you don\'t    say\\\"`"

(The above example indicated the quotes emitted in the output.)

That is, I expected that \" ->  " substitution would not happen inside
the ``'s outside of the context of the command substitution, since the
quotes do not need to be escaped in that context to be seen as quotes in
the substitution context.

The quotes NEED to be escaped in the quoted command substitution
context, since behavior is undefined if " quotes are not escaped inside

Okay, thanks. (Actually your other reply was the most helpful of the two :-).)

Please do not quote my e-mail address unobfuscated in message bodies.
Will your shell have salvation? Only if it's Bourne Again.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]