Xref: utzoo comp.lang.c:9372 comp.unix.wizards:7806 Path: utzoo!mnetor!uunet!steinmetz!ge-dab!codas!ateng!chip From: chip@ateng.UUCP (Chip Salzenberg) Newsgroups: comp.lang.c,comp.unix.wizards Subject: Re: command line options Message-ID: <221@ateng.UUCP> Date: 11 Apr 88 13:41:41 GMT Organization: A T Engineering, Tampa, FL Lines: 36 Keywords: Safety first What's so hard about typing '-\?' to get help? I do it all the time. And it works in any shell and despite strangely named files. BTW, the argument against '-?' that goes "but what if I have a file named '-r'" is not very strong, since such a file kills you even if you don't ask for help: % ls -F -r foo bar important/ % rm * [pronounced "rim splat", by the way] % ls % [anguished scream] Kaboom. For those of you who want to make your programs a bit safer to use than rm, here is an idea: Before parsing for options, check to see if any arguments that begin with '-' are actually the names of existing files. If they are, emit a suitably alarming warning message and enable the "interactive" option so the user has a chance to back out. And if you see an argument '--', check to see if a file by that name exists, then stop looping since the rest of the arguments are not options. Of course, this gets complicated by a call to isatty(), since you don't want a cron task waiting for operator input; so perhaps this ends up being more of a kludge than a safety belt. But if your program is sufficiently destructive, CYA is a worthwhile policy. -- Chip Salzenberg "chip@ateng.UU.NET" or "codas!ateng!chip" A T Engineering My employer's opinions are a trade secret. "Anything that works is better than anything that doesn't."