help-bash
[Top][All Lists]
Advanced

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

Re: Handling getopt for option without optional argument value


From: Lawrence Velázquez
Subject: Re: Handling getopt for option without optional argument value
Date: Fri, 23 Jul 2021 16:02:08 -0400
User-agent: Cyrus-JMAP/3.5.0-alpha0-540-g21c5be8f1e-fm-20210722.001-g21c5be8f

Returning to the original question.

On Fri, Jul 23, 2021, at 10:22 AM, lisa-asket@perso.be wrote:
> I have the following bash function but when I call it with
> 
> indus-printf-multiple -- "Test" "TNest"
> 
> the variable $warn is not being set to 1.
>
> [...] 
>
>         ("-w"|"--warning")
>           case "$2" in
>             (+([[:digit:]])) 
>               local warn="$2"
>               shift 2
>               ;;
>             (*) 
>               local warn="1"
>               shift 2
>               ;;
>             esac
>             declare -i local f=1
>             ;;

It looks like you only set "warn" when a '-w' or '--warning' option
is present, but nothing you've shown us indicates that you're passing
such an option.  So why should "warn" be set at all?

-- 
vq



reply via email to

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