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

2015-11-13 Thread Griff Miller II
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

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

2015-11-13 Thread Greg Wooledge
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

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

2015-11-13 Thread Dennis Williamson
On Fri, Nov 13, 2015 at 10:13 AM, Griff Miller II wrote: > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: cygwin > Compiler: gcc > Compilation CFLAGS: -DPROGRAM='bash.exe' -DCONF_HOSTTYPE='x86_64' > -DCONF_OSTYPE='cygwin'

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

2015-11-13 Thread Griff Miller II
On Fri, November 13, 2015 1:02 pm, Dennis Williamson wrote: > Your opts string needs to begin with a colon to enable silent error > reporting and you need to handle the colon in your case statement as the > condition where a required argument is missing. Hi, Dennis - thanks for replying. I get

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

2015-11-13 Thread Chet Ramey
On 11/13/15 11:13 AM, Griff Miller II wrote: > 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, so that > values starting with '-'