history expansion conflicts with variable expansion, maybe token parsing issue

Bug #622106 reported by Scott Merrilees
10
This bug affects 2 people
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)

Norbert (nrbrtx)
tags: added: precise
Revision history for this message
Norbert (nrbrtx) wrote :

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.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in bash (Ubuntu):
status: New → Confirmed
Norbert (nrbrtx)
tags: removed: precise
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.