* zparseopts and longopts
@ 2016-05-12 11:16 Atte Peltomaki
2016-05-13 11:25 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Atte Peltomaki @ 2016-05-12 11:16 UTC (permalink / raw)
To: zsh-users
Howdy hackers,
I'm seeing erratic behaviour when using zparseopts together with GNU
long options which have additional dashes and the first part before the
dash is common. Example:
---clip---
#!/bin/zsh
zparseopts -E -D -- -gnu:=gnu -gnu-tard:=gnutard
print -- $gnu\\n$gnutard
---clap---
Executing as intended:
% ./test.zsh --gnu argh --gnu-tard rms
--gnu argh
--gnu-tard rms
Executing with imaginary new option:
% ./test.zsh --gnu argh --gnu-tard rms --gnu-tard-added-even-longer-opt whyohwhy
--gnu argh
--gnu-tard -added-even-longer-opt
--
Atte Peltomäki
atte.peltomaki@iki.fi <> http://kameli.org
"Your effort to remain what you are is what limits you"
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: zparseopts and longopts
2016-05-12 11:16 zparseopts and longopts Atte Peltomaki
@ 2016-05-13 11:25 ` Bart Schaefer
2016-05-15 15:06 ` Atte Peltomaki
0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2016-05-13 11:25 UTC (permalink / raw)
To: Zsh Users; +Cc: Atte Peltomaki
On Thu, May 12, 2016 at 4:16 AM, Atte Peltomaki <atte.peltomaki@iki.fi> wrote:
> Executing with imaginary new option:
>
> % ./test.zsh --gnu argh --gnu-tard rms --gnu-tard-added-even-longer-opt whyohwhy
> --gnu argh
> --gnu-tard -added-even-longer-opt
Well, you've told zparseopts that --gnu-tard is an option that takes a
mandatory argument, and you have not told zparseopts that
--gnu-tard-add... is an option, and the argument of an option is
allowed to appear in the same word as the option itself (so that -a2
is the same as -a 2), so zparseopts believes -add... is the argument
of the option you told it about.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: zparseopts and longopts
2016-05-13 11:25 ` Bart Schaefer
@ 2016-05-15 15:06 ` Atte Peltomaki
0 siblings, 0 replies; 3+ messages in thread
From: Atte Peltomaki @ 2016-05-15 15:06 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Zsh Users
On Fri, May 13, 2016 at 04:25:28AM -0700, Bart Schaefer wrote:
> On Thu, May 12, 2016 at 4:16 AM, Atte Peltomaki <atte.peltomaki@iki.fi> wrote:
> > Executing with imaginary new option:
> >
> > % ./test.zsh --gnu argh --gnu-tard rms --gnu-tard-added-even-longer-opt whyohwhy
> > --gnu argh
> > --gnu-tard -added-even-longer-opt
>
> Well, you've told zparseopts that --gnu-tard is an option that takes a
> mandatory argument, and you have not told zparseopts that
> --gnu-tard-add... is an option, and the argument of an option is
> allowed to appear in the same word as the option itself (so that -a2
> is the same as -a 2), so zparseopts believes -add... is the argument
> of the option you told it about.
Makes sense, but also makes it impossible to use zparseopts with a
caller that may spontaneously add options and expect scripts to work
unmodified.
--
Atte Peltomäki
atte.peltomaki@iki.fi <> http://kameli.org
"Your effort to remain what you are is what limits you"
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-15 15:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-12 11:16 zparseopts and longopts Atte Peltomaki
2016-05-13 11:25 ` Bart Schaefer
2016-05-15 15:06 ` Atte Peltomaki
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).