bug-bash
[Top][All Lists]
Advanced

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

Re: bash: exclamation mark is not literal within double quotes


From: Chet Ramey
Subject: Re: bash: exclamation mark is not literal within double quotes
Date: Sun, 19 Dec 2004 12:29:08 -0500
User-agent: Mozilla Thunderbird 0.9 (Windows/20041103)

Richard Neill wrote:
May I suggest the following changes:

1)It is a bug that ! cannot be quoted within double quotes, not even by backslash. For example, the following ought to work: WARNING="Bad $USER\! Go $HOME\!" ; echo $WARNING

Do you mean that because the backslashes are not removed?

It is not a bug.  Bash is, above all, a POSIX shell.  The rules for
characters special within double quotes and the behavior of
backslash-escaped characters within double quotes are well-defined.

The csh-derived history expansion mechansism is a somehwat clumsy
addition.  This is one of the places where the two clash.

2)Shouldn't history expansion be off in a shell script anyway?

It is, unless you enable it.

3)Personally, I still find the paragraph (2) unclear. It seems to me that someone making a quick reference to quoting won't understand it.

I will take a look at making it more clear.

Please do change the behaviour to allow \! Otherwise, one has to write really contrived scripts such as: echo "Hello $USER"'!'" How are you?"

One doesn't have to do anything of the sort.  History expansion is not
enabled when the shell is not interactive, so script writers are able
to use "Hello $USER!"  If you want to make sure of that, to inoculate
yourself against a $BASH_ENV file that enables history expansion, for
instance, put `set +H' in the script.

Chet




reply via email to

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