feature request $UNEXPANDED_COMMANDLINE

Bug #425286 reported by John McCabe-Dansted
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: bash

"rm * .o" deletes all files. This is not a bug in rm since bash expands * to match all files. Strictly speaking it isn't a bug in bash either, but it would be nice if bash set a variable such as "UNEXPANDED_COMMANDLINE" so that we could alias rm to something like:

if echo $UNEXPANDED_COMMANDLINE | grep "[*] [.][[:alnum:]]]" >/dev/null
    echo I don\'t think you wanted to have a space between the '*' and the '.'
else
    rm "$@"
done

Note:
1) /proc/$$/cmdline give the expanded cmdline, so that is no use.
2) "set -f" isn't useful, unless I alias every command to do its own (safer) expansion.
3) To reproduce, repeat the following and note that the second ls doesn't see any files
$ ( mkdir -p tmp ; cd tmp && ( touch f.c f.o ; ls ; rm * .o ; ls ) )
f.c f.o
rm: cannot remove `.o': No such file or directory

ProblemType: Bug
Architecture: i386
CheckboxSubmission: 404bd18599e0899eb2769ef0d7f6c695
CheckboxSystem: 6944d89cd962d3dec0d4098e584fb8ff
Date: Mon Sep 7 00:10:10 2009
DistroRelease: Ubuntu 9.10
Package: bash 4.0-4ubuntu1
ProcEnviron:
 SHELL=/bin/bash
 PATH=(custom, user)
 LANG=en_AU.UTF-8
ProcVersionSignature: Ubuntu 2.6.31-9.29-generic
SourcePackage: bash
Tags: ubuntu-unr
Uname: Linux 2.6.31-9-generic i686

Revision history for this message
John McCabe-Dansted (gmatht) wrote :
Revision history for this message
Lesmana Zimmer (lesmana) wrote :

changed the title to better reflect the feature request.

i agree that stupid rm typos can be disastrous. if it can be done well i might also accept such filtering. but i doubt that it can be done in way that it is really "smart". tools trying to be smarter than the user, when they are not, usually annoy the hell out of me.

that said, i would really like to have a $UNEXPANDED_COMMANDLINE

summary: - "rm * .o" deletes all files
+ feature request $UNEXPANDED_COMMANDLINE
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.