*BSD News Article 80516


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mira.net.au!news.vbc.net!knews.uk0.vbc.net!newsfeed.easynet.co.uk!easynet-uk!www.nntp.primenet.com!nntp.primenet.com!news.texas.net!news.kei.com!newsfeed.internetmci.com!csn!nntp-xfer-1.csn.net!ncar!newshost.lanl.gov!crs
From: crs@lanl.gov (Charlie Sorsby)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: dummy question
Date: 12 Oct 1996 18:18:07 GMT
Organization: Los Alamos National Laboratory
Lines: 76
Message-ID: <53oncv$fi5@newshost.lanl.gov>
References: <53mfdu$1iv@wa4phy.async.com>
NNTP-Posting-Host: hamlet.lanl.gov

In article <53mfdu$1iv@wa4phy.async.com>,
S.W. Drinkard <sam@wa4phy.async.com> wrote:
= 
= Ok, I'm not exactly a newbie, but I created a file with a filename of
= "--remove-files" due to a blunder of the fingers.  SysV would let me 
= remove it in quotes, or by matching a wildcard patern.  I tried every
= combination of rm/mv/whatever short of the 45-cal pistol.  How does 
= *bsd do it?

I seem to remember that some version of Unix that I've used in the
past had a special option flag for some commands for just such a
purpose.  I believe it was "-" so that something like

% command - funny.file.name

(Note spaces on both sides of flag "-")

told command that funny.file.name is an argument and not an option
flag even if it began with a "-" but that doesn't seem to be the
case with FreeBSD.

Could commands where this would be useful be changed to behave that
way or is that considered encumbered code (or whatever it's called)?

Alternatively, something like the -e option to grep would be
helpful in such circumstances.

It seemed a sensible option to me who has been known to fat-finger
the keyboard at inopportune times.

Oddly, in spite of complaining, "rm - filename" seems to work:

PC% !cat
cat /dev/null > --remove-files
PC% ls
--remove-files  ./              ../
PC% !42
rm \-\-remove\-files
usage: rm [-dfiRr] file ...
PC% ls
--remove-files  ./              ../
PC% !40
rm -i *remove*
usage: rm [-dfiRr] file ...
PC% ls
--remove-files  ./              ../
PC% !41
rm - *remove*
rm: -: No such file or directory
PC% ls
./      ../
PC% 

The repeated commands are because the first time I tried this,
I didn't do an ls each time because I took the complaints at their
word and found out later that the file was gone.

PC% cat /dev/null > --remove-files
PC% rm - --remove-files
rm: -: No such file or directory
PC% ls
./      ../
PC% 

also works.

Being paranoid, I also tried it with another file in the directory
just to be sure it wasn't doing something bizarre like removing
everything.  It didn't.


-- 
Best,

Charlie "Older than dirt" Sorsby                         "I'm the NRA!"
       crs@swcp.com crs@hamlet.lanl.gov              Life Member since 1965