*BSD News Article 80638


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.EDU.AU!munnari.OZ.AU!spool.mu.edu!usenet.eel.ufl.edu!news.mathworks.com!howland.erols.net!EU.net!usenet2.news.uk.psi.net!uknet!usenet1.news.uk.psi.net!uknet!dispatch.news.demon.net!demon!awfulhak.demon.co.uk!awfulhak.demon.co.uk!usenet
From: brian@anorak.coverform.lan (Brian Somers)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: dummy question
Date: 13 Oct 1996 19:19:44 GMT
Organization: Coverform Ltd.
Lines: 41
Message-ID: <53rfcg$a7@anorak.coverform.lan>
References: <53mfdu$1iv@wa4phy.async.com> <53oncv$fi5@newshost.lanl.gov>
Reply-To: brian@awfulhak.demon.co.uk
NNTP-Posting-Host: anorak.coverform.lan
X-NNTP-Posting-Host: awfulhak.demon.co.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Newsreader: knews 0.9.8

In article <53oncv$fi5@newshost.lanl.gov>,
	crs@lanl.gov (Charlie Sorsby) writes:
> 
> 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.

I belive you're looking for "--" rather than "-".

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

This looks like a problem with getopt():

                /*
		 * if the user didn't specify '-' as an option,
		 * assume it means EOF.
		 */
		if (optopt == (int)'-')
			return (EOF);
		if (!*place)
			++optind;

I suspect this should be:

		if (!*place)
			++optind;
		if (optopt == (int)'-')
			return (EOF);

In FreeBSD (and BSD in generial I believe), '-' *may* be treated as a
valid flag if the program wishes.  If the program doesn't specifically
mention it, it behaves like "--".

-- 
Brian <brian@awfulhak.demon.co.uk>
      <http://www.awfulhak.demon.co.uk/>
Don't _EVER_ lose your sense of humour....