[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible bug in getopts when required argument is not supplied
From: |
Greg Wooledge |
Subject: |
Re: Possible bug in getopts when required argument is not supplied |
Date: |
Fri, 13 Nov 2015 13:56:16 -0500 |
User-agent: |
Mutt/1.4.2.3i |
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.