help-bash
[Top][All Lists]
Advanced

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

Handling getopt for option without optional argument value


From: lisa-asket
Subject: Handling getopt for option without optional argument value
Date: Fri, 23 Jul 2021 23:35:57 +0200 (CEST)

From: Lawrence Velázquez <vq@larryv.me>
To: lisa-asket@perso.be
Subject: Re: Handling getopt for option without optional argument value
Date: 23/07/2021 23:10:21 Europe/Paris
Cc: help-bash@gnu.org

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.



--- You are right.  The problem seems to have been associated with the code 
after that. 

When I was using [[ -v $warn ]], where it should have been [[ -v warn ]].





("-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.




reply via email to

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