Path: utzoo!attcan!uunet!mcvax!ukc!etive!hwcs!zen!frank From: frank@zen.co.uk (Frank Wales) Newsgroups: comp.sys.hp Subject: Re: Trying to remove a file called "-ls" Summary: option parsing Message-ID: <1540@zen.UUCP> Date: 12 Mar 89 18:07:15 GMT References: <570@sdrc.UUCP> <2087@helios.ee.lbl.gov> <2088@helios.ee.lbl.gov> <2089@helios.ee.lbl.gov> Reply-To: frank@zen.co.uk (Frank Wales) Organization: Zengrange Limited, Leeds, England Lines: 39 In article <2089@helios.ee.lbl.gov> leres@helios.ee.lbl.gov (Craig Leres) writes: >John Milburn writes: >>In article <570@sdrc.UUCP> diblanch@sdrc.UUCP (Jeff Blanchet) writes: >>>I seem to have stumbled across a bug that occurs on the HP. I created a file >>>called "-ls". Now on any other UNIX system all I have to do is issue the >>>command "rm -i *". I'd be surprised if this only complained on HP-UX. The behaviour you describe is what I'd expect on a Sys V machine which tries to be consistent about option parsing, simply treating the file name as if it were another set of command line switches. It is not a bug. >>Try rm "-ls". This definitely won't make any difference -- quoting is a shell mechanism for assembling arguments, and isn't perceived by the invoked commands. >This may work under hpux, but it doesn't under Berkeley Unix. My >favorate way to remove a file with a leading dash is: > > % rm foo -ls > >It doesn't matter if foo exists or not; once it sees an argument that >doesn't have a leading dash, it stops looking. But its exit status might be a problem if this is in a shell script, say. Now for the answer: to terminate option parsing on rm (and most other commands which accept command line switches), put a '--' in the command line. Beyond that, anything starting with a '-' won't be picked up as an option. So, to remove the offending file, use "rm -- -ls". This works on both 300 and 800 series HP-UX (and probably also 500). It is down to the individual command to recognise the '--' convention, though; your mileage may vary. -- Frank Wales, Systems Manager, [frank@zen.co.uk<->mcvax!zen.co.uk!frank] Zengrange Ltd., Greenfield Rd., Leeds, ENGLAND, LS9 8DB. (+44) 532 489048 x217