bug-bash
[Top][All Lists]
Advanced

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

Re: incorrect character handling


From: Greg Wooledge
Subject: Re: incorrect character handling
Date: Tue, 30 Mar 2021 16:50:10 -0400

On Wed, Mar 31, 2021 at 02:31:46AM +0700, by.sm--- via Bug reports for the GNU 
Bourne Again SHell wrote:
> poc=whoami
> $poc
> python3 -c "print('!!')"
> 
> That return 'whoami' command. 

You're running into the csh-style history expansion.  A lot of us simply
disable it, because it's not worth the effort it takes to work around it.

set +o histexpand


If you insist on keeping it, and working around it, the key is to
understand that single quotes will protect you, but double quotes may
not.

echo 'hi!'

echo "hi!"


The actual behavior of ! (history expansions) inside double quotes has
changed across bash versions, so you may have more problems, or fewer
problems, depending on your bash version.  But there will never be
zero problems.



reply via email to

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