[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bash: exclamation mark is not literal within double quotes
From: |
rn214 |
Subject: |
bash: exclamation mark is not literal within double quotes |
Date: |
Tue, 14 Dec 2004 04:48:20 +0000 (GMT) |
Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i586'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i586-mandrake-linux-gnu'
-DCONF_VENDOR='mandrake' -DSHELL -DHAVE_CONFIG_H -I. -I.. -I../include
-I../lib -D_GNU_SOURCE -O2 -fomit-frame-pointer -pipe -march=i586
-mtune=pentiumpro
uname output: Linux mocha.baddiant.org.uk 2.6.8.1-12mdksmp #1 SMP Fri Oct 1
11:24:45 CEST 2004 i686 Intel(R) Pentium(R) 4 CPU 3.00GHz unknown GNU/Linux
Machine Type: i586-mandrake-linux-gnu
Bash Version: 2.05b
Patch Level: 0
Release Status: release
Description:
Error in the documentation. The manual says:
>> Enclosing characters in double quotes preserves the literal value
of
>> all characters within the quotes, with the exception of $, `, and
\.
>> The characters $ and ` retain their special meaning within
double
>> quotes. The backslash retains its special meaning only when
followed
>> by one of the following characters: $, `, ", \, or <newline>. A
double
>> quote may be quoted within double quotes by preceding it with a
back-
>> slash.
This is not true. For example according to the above,
echo "foo!bar"
should yield exactly the same result as
echo 'foo!bar'
i.e., it should print
foo!bar
yet it does not. It generates an error message:
bash: !bar": event not found
Repeat-By:
Double quoting an exclamation mark (except when it is followed by a
space)
Fix:
Since this behaviour is intentional (history expansion), it is a
documentation bug.
I'd like to see 3 changes:
1)Fix the documentation on double quoting to explain that ! is not
literal
within double quotes
2)Allow ! to be escaped with backslash. Eg:
echo "foo\!bar"
3)The error generated above "event not found" isn't very informative to
a user who is expecting
a double-quoted literal exclamation mark. Perhaps it could be clearer?
Thank you very much
Richard
- bash: exclamation mark is not literal within double quotes,
rn214 <=