history expansion conflicts with variable expansion, maybe token parsing issue
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| bash (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned | ||
Bug Description
Binary package hint: bash
$ cat /etc/issue
Ubuntu 10.04.1 LTS \n \l
$ echo $BASH_VERSION
4.1.5(1)-release
$ sleep 5 & pid=$!
$ sleep 5 & pid=$!; echo $pid
bash: !: event not found
$ sleep 5 & pid=$! ; echo $pid
3434
$ (sleep 5 & pid=$!; echo $pid)
bash: !: event not found
$ (sleep 5 & pid=$\!; echo $pid)
$!
$ {sleep 5 & pid=$!; echo $pid;}
bash: !: event not found
$
Seems like the workaround is to include whitespace after the $!, however that doesn't help existing scripts.
$ aptitude show bash
Package: bash
Essential: yes
State: installed
Automatically installed: no
Version: 4.1-2ubuntu3
Priority: required
Section: shells
Maintainer: Ubuntu Developers <email address hidden>
Uncompressed Size: 3,576k
Depends: base-files (>= 2.1.12), debianutils (>= 2.15)
PreDepends: dash, libc6 (>= 2.11), libncurses5 (>= 5.6+20071006-3)
Recommends: bash-completion (>= 20060301-0)
Suggests: bash-doc
Conflicts: bash-completion (< 20060301-0)
Replaces: bash-completion (< 20060301-0), bash-doc (<= 2.05-1)

I discovered that bash can't work with files with "!" in their names.
Thi bug presents in Precise 12.04 with bash 4.2-2ubuntu2.
So the following commands not work too:
$touch !file.txt
bash: !file.txt: event not found
$touch file!.txt
bash: !.txt: event not found
If I manually escape the "!" character, all commands work.
The sh shell works normally with and without escaping, but it have no auto-completion.