Advertisement
adfaklsdjf

unix sucks

Aug 2nd, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. http://m.simson.net/ugh.pdf
  2.  
  3. We mentioned that the shell performs wildcard expansion
  4. that is
  5. 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
  6. programs accept their options as their first argument
  7. usually preceded by a dash (–). This is flaw #2. Options (switches) and other arguments should be separate entities
  8. as they are on VMS
  9. DOS
  10. Genera
  11. and many other operationg systems. Finally
  12. Unix filenames can contain most characters
  13. including nonprinting ones. This is flaw #3. These architectural choices interact badly. The shell lists files alphabetically when expanding “*”
  14. and the dash (-) comes first in the lexicographic caste system. Therefore
  15. filenames that begin with a dash (-) appear first when “*” is used. These filenames become options to the invoked program
  16. yielding unpredictable
  17. surprising
  18. and dangerous behavior.
  19.  
  20. Date: Wed
  21. 10 Jan 90 10:40 CST
  22. From: kgg@lfcs.ed.ac.uk (Kees Goossens)
  23. Subject: Re: rm *
  24. Newsgroups: alt.folklore.computers
  25.  
  26. Then there’s the story of the poor student who happened to have a
  27. file called “-r” in his home directory. As he wanted to remove all his
  28. non directory files (I presume) he typed:
  29.  
  30. % rm *
  31.  
  32. ...And yes
  33. it does remove everything except the beloved “-r” file... Luckily our backup system was fairly good.
  34.  
  35.  
  36. 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
  37. presumably
  38. ask for confirmation before deleting each file. Not a bad solution
  39. that
  40. 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