Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://m.simson.net/ugh.pdf
- We mentioned that the shell performs wildcard expansion
- that is
- it replaces the star (*) with a listing of all the files in a directory. This is flaw #1; the program should be calling a library to perform wildcard expansion. By convention
- programs accept their options as their first argument
- usually preceded by a dash (–). This is flaw #2. Options (switches) and other arguments should be separate entities
- as they are on VMS
- DOS
- Genera
- and many other operationg systems. Finally
- Unix filenames can contain most characters
- including nonprinting ones. This is flaw #3. These architectural choices interact badly. The shell lists files alphabetically when expanding “*”
- and the dash (-) comes first in the lexicographic caste system. Therefore
- filenames that begin with a dash (-) appear first when “*” is used. These filenames become options to the invoked program
- yielding unpredictable
- surprising
- and dangerous behavior.
- Date: Wed
- 10 Jan 90 10:40 CST
- From: kgg@lfcs.ed.ac.uk (Kees Goossens)
- Subject: Re: rm *
- Newsgroups: alt.folklore.computers
- Then there’s the story of the poor student who happened to have a
- file called “-r” in his home directory. As he wanted to remove all his
- non directory files (I presume) he typed:
- % rm *
- ...And yes
- it does remove everything except the beloved “-r” file... Luckily our backup system was fairly good.
- Some Unix victims turn this filename-as-switch bug into a “feature” by keeping a file named “-i” in their directories. Type “rm *” and the shell will expand this to “rm -i filenamelist” which will
- presumably
- ask for confirmation before deleting each file. Not a bad solution
- that
- as long as you don’t mind putting a file named “-i” in every directory. Perhaps we should modify the mkdir command so that the “-i” file gets created automatically. Then we could modify the ls command not to show it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement