* zoptargs usage to place multiple values into an array
@ 2022-09-28 22:01 Zach Riggle
2022-09-29 22:54 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Zach Riggle @ 2022-09-28 22:01 UTC (permalink / raw)
To: Zsh Users
I know this is in the documentation, but what is the incantation to
zoptargs to permit multiple command line **values**?
Desired CLI:
$ ./script.zsh --arg value1 --arg value2 --arg value3
Desired effect in script:
declare -a arg=( value1 value2 value3 )
What's the appropriate zoptargs incantation to get this effect?
Zach Riggle
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: zoptargs usage to place multiple values into an array
2022-09-28 22:01 zoptargs usage to place multiple values into an array Zach Riggle
@ 2022-09-29 22:54 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2022-09-29 22:54 UTC (permalink / raw)
To: Zach Riggle; +Cc: Zsh Users
On Wed, Sep 28, 2022 at 3:01 PM Zach Riggle <zachriggle@gmail.com> wrote:
>
> I know this is in the documentation, but what is the incantation to
> zoptargs to permit multiple command line **values**?
You mean zparseopts? OPTARG is a variable used by the getopts builtin.
> Desired CLI:
>
> $ ./script.zsh --arg value1 --arg value2 --arg value3
>
> Desired effect in script:
>
> declare -a arg=( value1 value2 value3 )
You can't get that directly. If you use
zparseopts - -arg+:=arg
Then you get
arg=(--arg value1 --arg value2 --arg value3)
from which you have to delete the "--arg" elements yourself, e.g.
arg=(${arg:#--arg})
Is that close enough?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-29 22:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 22:01 zoptargs usage to place multiple values into an array Zach Riggle
2022-09-29 22:54 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).