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 17:10:21 -0400
User-agent: Cyrus-JMAP/3.5.0-alpha0-540-g21c5be8f1e-fm-20210722.001-g21c5be8f

On Fri, Jul 23, 2021, at 4:53 PM, lisa-asket@perso.be wrote:
> From: Lawrence Velázquez <vq@larryv.me>
> 
> This wouldn't fix anything. The `warn` variable would still only
> get set when '-w' or '--warning' is passed to your function.
> 
> ---
> 
> Correct.  Warn is only used so that some lines are coloured in red.

So. What. Is. The. Problem.

> I do not think `(*)` is called when having just `-w`.

It is.  You can verify this trivially.

       ("-w"|"--warning")
         case "$2" in
           (+([[:digit:]])) 
             local warn="$2"
             shift 2
             ;;
           (*) 
+            printf 'warned!\n' >&2
             local warn="1"
             shift 2
             ;;
           esac
           declare -i local f=1
           ;;


> I don't understand what you want at all. Isn't the current behavior
> fine? Why would you want `warn` to be set by default? What is the
> behavior you are seeing, and what are you expecting instead?

Answer these questions.

-- 
vq



reply via email to

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