Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11878

Re: Possible bug in getopts when required argument is not supplied

From "Griff Miller II" <griff.miller@oplink.net>
Newsgroups gnu.bash.bug
Subject Re: Possible bug in getopts when required argument is not supplied
Date 2015-11-13 13:57 -0600
Message-ID <mailman.2285.1447444647.7904.bug-bash@gnu.org> (permalink)
References <535058272b68c9459882c6bd4565b428.squirrel@webmail.oplink.net> <20151113185616.GH27325@eeg.ccf.org>

Show all headers | View raw


On Fri, November 13, 2015 12:56 pm, Greg Wooledge wrote:
> On Fri, Nov 13, 2015 at 10:13:15AM -0600, Griff Miller II wrote:
>
>> % ./myscript -a -b b
>>
>>
>> Note that in the last run, getopts does not detect that nothing was
>> passed via -a, even though -a requires it. Instead, it thinks the next
>> switch (-b) is the value of -a. Perhaps this was a conscious decision,
>>
>
> Yes, it is.
>
>
> If you want your script to disallow arguments of -a that begin with a
> hyphen character, you will have to check for that yourself.

Well, there you go.  :)  Thanks for replying. I do currently have just
such a workaround implemented. Any chance of making this behavior clearer
in the man page?

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Possible bug in getopts when required argument is not supplied "Griff Miller II" <griff.miller@oplink.net> - 2015-11-13 13:57 -0600

csiph-web