bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Griff Miller II
Subject: Re: Possible bug in getopts when required argument is not supplied
Date: Fri, 13 Nov 2015 13:54:32 -0600
User-agent: SquirrelMail/1.5.2 [SVN]

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 the same behavior with silent
reporting. My real script where I discovered this behavior actually uses
silent reporting - I didn't use it in my example to keep things simple.

> Snippets:
>
>
> opts=:a:b:c
>
>
> :) echo "Missing argument for option -$OPTARG" >&2;;
>
>
> You should escape the question mark since otherwise it's a globbing
> character:

You are right! I missed that when throwing together my example script.

> \?) echo "Unknown option: -$OPTARG" >&2; exit 1;;
>
>
> --
> Visit serverfault.com to get your system administration questions
> answered.
>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]