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: Mon, 21 Apr 2014 22:16:51 +1200

After looking into the code, it turns out it's because history_expand
basically works as a finite state machine to determine whether it
should expand occurances of ! it runs into, so of course can't handle
subcommands (more specifically, quotes inside quotes). This leads to
interesting patterns though:

echo '!!' # doesn't expand
echo "$(echo '!!')" # expands
echo "$(echo "$(echo '!!')")" # doesn't expand
echo "$(echo "$(echo "$(echo '!!')")")" # expands
echo "$(echo "$(echo "$(echo "$(echo '!!')")")")" # doesn't expand

The reason it appeared to work in 2.05b was because it simply didn't
account for double quotes, which meant it had things like:
echo \' !! \' # expands
echo "'" !! "'" # doesn't expand

This seems like an architectural issue, so I probably wouldn't be able
to fix it myself (I've never looked at bash's source until
now)—logically, I'd expect the history expansion to happen in the same
place as the variable use expansion, but there must be a reason that's
not the case.



reply via email to

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