RESEARCHUT -- Minds With Innovations
RESEARCHUT
Minds With Innovations

RESEARCHUT - minds with innovations

This site has been archived. The new interface is: HERE

rm \- "-" ??

Sunday 01 July 2007 at 3:17 pm. Used tags:

Does anyone know when really did coreutils get patched for this behavior ?

rrs@learner:~$ rm -foo
rm: invalid option -- o
Try `rm ./-foo' to remove the file `-foo'.
Try `rm --help' for more information.
This feature really wasn't earlier and if you ever ended up with files starting with characters like "-", it was not a straight task to remove it.

Earlier (when I wasn't aware of this patch), the workaround was to write a small 1 liner and not use getopt at all. Something like:

rrs@learner:~$ cat rm.py
#!/usr/bin/env python

import os, sys

sys.stdout.write("Removing file %s.\n" % (sys.argv[1]) )
os.unlink(sys.argv[1])

I'm really happy to see this bug fixed.

four comments

आजीष जुक्ल
rm -- -foo

Use "--" (2 hyphens) as command line argument, if you've file names starting with "-" in coreutils . आजीष जुक्ल (URL) - 01-07-’07 22:06
Ashish Shukla
Just noticed your blogging software doesn't support UTF-8. Ashish Shukla (URL) - 01-07-’07 22:08
Ritesh Raj Sarraf
I've changed it to UTF-8 now. Ritesh Raj Sarraf - 02-07-’07 22:28
आशीष शुक्ल
Cool and its working. Thanks आशीष शुक्ल (URL) - 02-07-’07 22:32


(optional field)
(optional field)
Sorry for the trouble but to prevent spam I require you to answer this silly question.

Comment moderation is enabled on this site. This means that your comment will not be visible until it has been approved by an editor.

Remember personal info?
Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.