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


Groups > gnu.bash.bug > #11876

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

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: Possible bug in getopts when required argument is not supplied
Date 2015-11-13 13:56 -0500
Message-ID <mailman.2281.1447440983.7904.bug-bash@gnu.org> (permalink)
References <535058272b68c9459882c6bd4565b428.squirrel@webmail.oplink.net>

Show all headers | View raw


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.

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


Thread

Re: Possible bug in getopts when required argument is not supplied Greg Wooledge <wooledg@eeg.ccf.org> - 2015-11-13 13:56 -0500

csiph-web