[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Question about escaping in backquote string in double qu
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] Question about escaping in backquote string in double quoted strings |
Date: |
Tue, 14 May 2019 13:55:18 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
On 5/2/19 2:52 PM, Andy Chu wrote:
> On Thu, May 2, 2019 at 10:56 AM Greg Wooledge <address@hidden> wrote:
>
>> On Fri, May 03, 2019 at 01:05:47AM +0800, KHMan wrote:
>>> echo "[` echo \" \\" \" `]" # [ " ] (A)
>>
>>> So my question is, what did bash do in (A), which seems to affect the
>>> specific case of the double quote char only?
>>
>> At this point you either run away screaming, or you just admit that
>> everyone was *correct* when they told you that you should use $(...)
>> instead of `...` because backslash handling inside `...` is too surprising.
>>
>
> Yeah I would agree to just use $() and get on with life. It's accepted
> everywhere, so you can safely modify existing shell scripts to use $()
> instead of `` whenever there's an issue.
This is the best choice without a doubt.
> I implemented part of the surprising behavior of \" inside `` for OSH
> recently, because virtualenv depended on it. I was not able to come up
> with any rule that didn't involve special cases for a specific number of
> backslashes.
The real difference is whether or not the command substitution occurs
within double quotes.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU address@hidden http://tiswww.cwru.edu/~chet/