weemba@garnet.berkeley.edu (Obnoxious Math Grad Student) (11/19/88)
In article <564@comdesign.CDI.COM>, pst@canary (Paul Traina) writes: >However, 'rm -f * .o' means do it, yes I mean it, don't ask stupid >questions. I would use it in a shell script no doubt. Now of course, >it's pretty unlikely that's what I meant. And while you're at it, don't forget the problem of the lexicograph- ically first file being named "-f". You know. That could make for a cutesy pie variant of the Morris worm. Just deposit "innocent" files named "-x" for various values of `x' in random directories. Confuse and annoy the hell out of people for a few minutes whenever they type * as part of a command. This game won't work with "<name" and ">name" though. Awwww. ucbvax!garnet!weemba Matthew P Wiener/Brahms Gang/Berkeley CA 94720
ark@alice.UUCP (Andrew Koenig) (11/20/88)
In article <17247@agate.BERKELEY.EDU>, weemba@garnet.berkeley.edu (Obnoxious Math Grad Student) writes: > And while you're at it, don't forget the problem of the lexicograph- > ically first file being named "-f". If your rm command uses getopt, you can remove a file named "-f" by saying rm -- -f or even rm -f -- -f The `--' is a widget that says `There are no more options after this; everything else is an argument even if it looks like an option.' -- --Andrew Koenig ark@europa.att.com
ekrell@hector.UUCP (Eduardo Krell) (11/20/88)
In article <8445@alice.UUCP> ark@alice.UUCP (Andrew Koenig) writes: >If your rm command uses getopt, you can remove a file named "-f" by saying > > rm -- -f What's wrong with good old "rm ./-f" ? This works regardless of getopt. Eduardo Krell AT&T Bell Laboratories, Murray Hill, NJ UUCP: {att,decvax,ucbvax}!ulysses!ekrell Internet: ekrell@ulysses.att.com
gwyn@smoke.BRL.MIL (Doug Gwyn ) (11/20/88)
In article <17247@agate.BERKELEY.EDU> weemba@garnet.berkeley.edu (Obnoxious Math Grad Student) writes: >And while you're at it, don't forget the problem of the lexicograph- >ically first file being named "-f". In a general-purpose shell script, one would want to use the -- option list terminator to avoid this problem. (Some systems still don't fully support the UNIX command language syntax standard, though.)
weemba@garnet.berkeley.edu (Obnoxious Math Grad Student) (11/20/88)
In article <8445@alice.UUCP>, ark@alice (Andrew Koenig) writes: >In article <17247@agate.BERKELEY.EDU>, weemba@garnet.berkeley.edu (Obnoxious Math Grad Student) writes: >> And while you're at it, don't forget the problem of the lexicograph- >> ically first file being named "-f". >If your rm command uses getopt, you can remove a file named "-f" by saying > rm -- -f I'm not asking about how to remove the file (thanks, anyway, although I see the how-many-ways-to-do-so discussion is starting up again): I'm just saying that "while you're at it [ie, `fixing' rm *]", you as might as well consider the problem of the user who wants to remove some of his files, and types "rm -i *", expecting to get interactive prompting, and instead has all his files removed. If the first file is "-f", you now have one unhappy user. "rm -i -- *" will avoid this problem, but I don't expect a lot of people to get into the habit of typing "--" here and in similar situations. ucbvax!garnet!weemba Matthew P Wiener/Brahms Gang/Berkeley CA 94720
mike@turing.unm.edu (Michael I. Bushnell) (11/20/88)
In article <17263@agate.BERKELEY.EDU> weemba@garnet.berkeley.edu (Obnoxious Math Grad Student) writes: >I'm not asking about how to remove the file (thanks, anyway, although >I see the how-many-ways-to-do-so discussion is starting up again): I'm >just saying that "while you're at it [ie, `fixing' rm *]", you as might >as well consider the problem of the user who wants to remove some of his >files, and types "rm -i *", expecting to get interactive prompting, and >instead has all his files removed. If the first file is "-f", you now >have one unhappy user. Actually you don't: Script started on Sat Nov 19 22:42:02 1988 turing.unm.edu 1 ls foo turing.unm.edu 2 touch ./-f turing.unm.edu 3 ls -f foo turing.unm.edu 4 rm -i * rm: remove foo? y turing.unm.edu 5 ls -f turing.unm.edu 6 ^D script done on Sat Nov 19 22:42:23 1988 All that happens is that ./-f isn't removed. As the man page *and* the source (RTFS, you know...) say, -f prevents error messages and the asking of questions for files you can't write. N u m q u a m G l o r i a D e o \ Michael I. Bushnell \ HASA - "A" division /\ mike@turing.unm.edu / \ {ucbvax,gatech}!unmvax!turing.unm.edu!mike