[getopt-sig] ANNOUNCE: Optik 1.3 released
David Boddie
david@sleepydog.net
Mon, 15 Apr 2002 14:52:21 +0100
On Friday 12 Apr 2002 9:45 pm, David Goodger wrote:
> David Boddie wrote:
> > <yourscript> -q -f -o -u -t -F -i -l -e
> >
> > Is this regarded as bad style?
>
> Yes, and wrong too. Either the -f option takes an argument, or it doesn't.
> Optik is explicit about this. Some people want optional option arguments,
> but that makes parsing (in cases like this) ambiguous and is best avoided.
I'd only seen that sort of option expansion in cases where each option
requires no following arguments (e.g. -abc = -a -b -c).
The only cases I've ever encountered where an argument is appended to a
single character option have been where only one option is being used
(e.g. -fname = -f name rather than -qfname = -q -f name).
There are obviously other variations I hadn't considered.
> Let's assume that -q doesn't take an argument. If the -f option *does* take
> an argument, then '-qfoutfile' is the same as '-q -f outfile'. If -f
> *doesn't* take an argument, then '-qfoutfile' may be parsed as '-q -f -o -u
> ...', which may or may not work, depending if -o, -u, etc., are defined.
Presumably you don't allow this:
-q -f outfil -e
David
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________