bug-bash
[Top][All Lists]
Advanced

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

Re: Expansion of exclamation mark in single quotes in subcommand


From: Maxdamantus
Subject: Re: Expansion of exclamation mark in single quotes in subcommand
Date: Tue, 22 Apr 2014 02:45:54 +1200

It's not just inside a double-quoted block. It's inside a single-quoted block.

The last two commands in my first email demonstrate that the $
expansion is aware of that, so it follows the rule of everything
inside single-quote blocks being literal except for the single quote
itself. ! doesn't.

echo "$(echo "$$")" # here, $$ is double-quoted, so should be expanded
to something (it is)
echo "$(echo '$$')" # here, $$ is single-quoted, so shouldn't be
expand to something (it isn't)
echo "$(echo "!!")" # here, !! is double-quoted, so should be expanded
to something (it is)
echo "$(echo '!!')" # here, !! is single-quoted, so shouldn't be
expanded to something (it is—this seems wrong)

I think my second email shows even more clearly that it's a bug: each
time you nest a subcommand, the behaviour changes: it alternates
between expanding an non-expanding

On 22 April 2014 02:26, Chris Down <chris@chrisdown.name> wrote:
> Maxdamantus writes:
>> This seems like a bug, but it seems to have been here for a few years
>> (from the git repository, bash-3.0 displays this behaviour while
>> bash-2.05b doesn't).
>>
>> With history expansion enabled (set +H):
>>
>> $ echo '!!' # good
>> !!
>> $ echo "$(echo '!!')" # not good; !! expands
>> echo "$(echo 'echo '!!'')"
>> echo !!
>> $ echo '$$' # good
>> $$
>> $ echo "$(echo '$$')" # good
>> $$
>
> I'm not totally sure why you think this is a bug. How can bash know what
> quoting style was used inside the command substitution? This is normal
> behaviour when history expansion is performed inside a double quoted
> block.
>
> Perhaps if you explained the reason you think this is a bug better,
> someone could give a more meaningful reply. :-)



reply via email to

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