bug-bash
[Top][All Lists]
Advanced

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

Re: Escaping the history expansion character


From: Chet Ramey
Subject: Re: Escaping the history expansion character
Date: Sun, 08 Aug 2004 22:08:18 -0400
User-agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.6) Gecko/20040113

Matthew Walker wrote:

 From the bash info page:
  Only `\' and `'' may be used to escape the history expansion
  character.

I have tried the following:
  echo '!'   # works fine, displays "!"
  echo "!"   # errors as expected with "event not found"
  echo "\!"  # produces "\!" --- this is my problem

Why is it that "\!" doesn't output just "!"?

For every other scenario "\x" produces "x". Why does this fail for an exclamation mark?

Because `!' is not one of the characters for which the backslash retains
its meaning as an escape character when in double quotes.

See

http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_02_03

for that list of characters.

This is one of the places where the csh-derived history expansion
collides with bash's sh-based syntax.

Chet




reply via email to

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