* "zstyle -L" doesn't quote properly
@ 2021-04-07 16:42 Bart Schaefer
2021-04-07 17:36 ` Daniel Shahaf
0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2021-04-07 16:42 UTC (permalink / raw)
To: Zsh hackers list
This occurs as a result of a typo when defining the style (the word
"menu" is misplaced after a copy/paste/edit) but produces garbage
output. I think the assumption is that in the syntax ...
zstyle [ -e | - | -- ] PATTERN STYLE STRING ...
... the STYLE must be a simple word and therefore doesn't need
quoting, but in fact the command will accept any sort of string in
that position.
% zstyle -e ':completion::*:default' '[[ $WIDGET =
(|reverse-)menu-complete ]] && reply=(menu yes select interactive)'
% zstyle -L
zstyle -e ':completion::*:default' [[ $WIDGET =
(|reverse-)menu-complete ]] && reply=(menu yes select interactive)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: "zstyle -L" doesn't quote properly
2021-04-07 16:42 "zstyle -L" doesn't quote properly Bart Schaefer
@ 2021-04-07 17:36 ` Daniel Shahaf
2021-04-07 18:12 ` Bart Schaefer
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Shahaf @ 2021-04-07 17:36 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Zsh hackers list
Bart Schaefer wrote on Wed, Apr 07, 2021 at 09:42:12 -0700:
> This occurs as a result of a typo when defining the style (the word
> "menu" is misplaced after a copy/paste/edit) but produces garbage
> output. I think the assumption is that in the syntax ...
>
> zstyle [ -e | - | -- ] PATTERN STYLE STRING ...
>
> ... the STYLE must be a simple word and therefore doesn't need
> quoting, but in fact the command will accept any sort of string in
> that position.
>
> % zstyle -e ':completion::*:default' '[[ $WIDGET =
> (|reverse-)menu-complete ]] && reply=(menu yes select interactive)'
> % zstyle -L
> zstyle -e ':completion::*:default' [[ $WIDGET =
> (|reverse-)menu-complete ]] && reply=(menu yes select interactive)
Here's a test.
Right now it prints "ke\x83 y", i.e., the correct value, but metafied
and not escaped.
I'll go ahead and commit it, but whoever is working on a fix, feel free
to tweak/extend it as needed.
Cheers,
Daniel
.oO( type-safety for metafied/tokenized/verbatim strings )
diff --git a/Test/V05styles.ztst b/Test/V05styles.ztst
index 048751941..3fcedfef1 100644
--- a/Test/V05styles.ztst
+++ b/Test/V05styles.ztst
@@ -164,3 +164,12 @@
0:the example in the documentation remains correct
>snow
>snow
+
+ (
+ zstyle $'con\x00text' $'ke\x00y' $'val\x00u' $'e'
+ a=( ${(f)"$(zstyle -L)"} )
+ a=( ${(M)a:#*con*text*ke*y*val*u*e} )
+ print -r -- "$a"
+ )
+-f:zstyle -L escapes the key (regression: workers/48424)
+>zstyle $'con\C-@text' $'ke\C-@y' $'val\C-@u' e
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: "zstyle -L" doesn't quote properly
2021-04-07 17:36 ` Daniel Shahaf
@ 2021-04-07 18:12 ` Bart Schaefer
2021-04-07 18:24 ` Daniel Shahaf
0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2021-04-07 18:12 UTC (permalink / raw)
To: Daniel Shahaf; +Cc: Zsh hackers list
On Wed, Apr 7, 2021 at 10:36 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>
> I'll go ahead and commit it, but whoever is working on a fix, feel free
> to tweak/extend it as needed.
I don't know how soon I'd be able to look at a fix, but there are two
ways we could go here: One, change the quoting for -L, or two, change
the code that defines styles to prohibit strings that need quoting in
that syntactic position.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: "zstyle -L" doesn't quote properly
2021-04-07 18:12 ` Bart Schaefer
@ 2021-04-07 18:24 ` Daniel Shahaf
2021-04-07 19:21 ` Peter Stephenson
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Shahaf @ 2021-04-07 18:24 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote on Wed, 07 Apr 2021 18:12 +00:00:
> On Wed, Apr 7, 2021 at 10:36 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> >
> > I'll go ahead and commit it, but whoever is working on a fix, feel free
> > to tweak/extend it as needed.
>
> I don't know how soon I'd be able to look at a fix, but there are two
> ways we could go here: One, change the quoting for -L, or two, change
> the code that defines styles to prohibit strings that need quoting in
> that syntactic position.
I assumed we'd take the former option and wrote the test accordingly,
but if we decide on some behaviour other than what the test expects, we
can adjust it accordingly.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: "zstyle -L" doesn't quote properly
2021-04-07 18:24 ` Daniel Shahaf
@ 2021-04-07 19:21 ` Peter Stephenson
2021-04-07 19:43 ` Bart Schaefer
0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2021-04-07 19:21 UTC (permalink / raw)
To: zsh-workers
On Wed, 2021-04-07 at 18:24 +0000, Daniel Shahaf wrote:
> Bart Schaefer wrote on Wed, 07 Apr 2021 18:12 +00:00:
> > On Wed, Apr 7, 2021 at 10:36 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > >
> > > I'll go ahead and commit it, but whoever is working on a fix, feel free
> > > to tweak/extend it as needed.
> >
> > I don't know how soon I'd be able to look at a fix, but there are two
> > ways we could go here: One, change the quoting for -L, or two, change
> > the code that defines styles to prohibit strings that need quoting in
> > that syntactic position.
>
> I assumed we'd take the former option and wrote the test accordingly,
> but if we decide on some behaviour other than what the test expects, we
> can adjust it accordingly.
Using the same function as everywhere else in that neighbourhood, we get
zstyle -e ':completion::*:default' $'[[ $WIDGET =\n(|reverse-)menu-complete ]] && reply=(menu yes select interactive)'
is that OK? If so it's just a question of updating the test.
./V05styles.ztst: starting.
Test ./V05styles.ztst was expected to fail, but passed.
Was testing: zstyle -L escapes the key (regression: workers/48424)
./V05styles.ztst: test XPassed.
pws
diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c
index cecea6d51..691ba6c2f 100644
--- a/Src/Modules/zutil.c
+++ b/Src/Modules/zutil.c
@@ -200,7 +200,8 @@ printstylenode(HashNode hn, int printflags)
else {
printf("zstyle %s", (p->eval ? "-e " : ""));
quotedzputs(p->pat, stdout);
- printf(" %s", s->node.nam);
+ putchar(' ');
+ quotedzputs(s->node.nam, stdout);
}
for (v = p->vals; *v; v++) {
putchar(' ');
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: "zstyle -L" doesn't quote properly
2021-04-07 19:21 ` Peter Stephenson
@ 2021-04-07 19:43 ` Bart Schaefer
0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2021-04-07 19:43 UTC (permalink / raw)
To: Peter Stephenson; +Cc: Zsh hackers list
On Wed, Apr 7, 2021 at 12:22 PM Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
>
> Using the same function as everywhere else in that neighbourhood, we get
>
> zstyle -e ':completion::*:default' $'[[ $WIDGET =\n(|reverse-)menu-complete ]] && reply=(menu yes select interactive)'
>
> is that OK? If so it's just a question of updating the test.
I think that works. quotedzputs() omits the quotes for simple words
so the output won't change for most people's existing settings.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-04-07 19:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 16:42 "zstyle -L" doesn't quote properly Bart Schaefer
2021-04-07 17:36 ` Daniel Shahaf
2021-04-07 18:12 ` Bart Schaefer
2021-04-07 18:24 ` Daniel Shahaf
2021-04-07 19:21 ` Peter Stephenson
2021-04-07 19:43 ` 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).