Maybe I'm missing something huge, but getopt(1,3) aren't working the way I
think they should.

I have a script that I want to take two options, both of which have required
arguments.

gabby# getopt k:s: -k
getopt: option requires an argument -- k
 --
gabby# getopt k:s: -s
getopt: option requires an argument -- s
 --
gabby#

Ok, so far, so good.  But now let's combine them:

gabby# getopt k:s: -k arg1 -s arg2
 -k arg1 -s arg2 --

Ok, looks fine.

gabby# getopt k:s: -k -s
 -k -s --
gabby#

Wha?  Neither of these options specified arguments!  I guess you could
consider that -k's argument was '-s', but I was pretty sure that an option's
argument couldn't start with a dash character (to avoid the ambiguity that
I'm hitting right now.)

I'm pretty sure I'm the one that's confused (not getopt), since I get the
same behaviour on -STABLE and -CURRENT.  Can someone tell me how to
accomplish what I want to do?  Basically, I want this:

gabby# getopt k:s: -k arg1 -s
getopt: option requires an argument -- k
 -k arg1 --
gabby# getopt k:s: -k -s arg2
getopt: option requires an argument -- k
 -s arg2 --
gabby#

--
Matt Emmerton


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to