* Quoted parameter parsing glitch
@ 2001-08-22 15:54 Bart Schaefer
2001-08-22 16:21 ` Borsenkow Andrej
0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2001-08-22 15:54 UTC (permalink / raw)
To: zsh-workers
schaefer<502> print "${foo:-"}"
dquote braceparam>
At this point the parser is in an infinite loop. There's nothing you can
type (except end-of-file or interrupt) that will free you from the PS2
prompt.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Quoted parameter parsing glitch
2001-08-22 15:54 Quoted parameter parsing glitch Bart Schaefer
@ 2001-08-22 16:21 ` Borsenkow Andrej
2001-08-22 16:59 ` Bart Schaefer
0 siblings, 1 reply; 7+ messages in thread
From: Borsenkow Andrej @ 2001-08-22 16:21 UTC (permalink / raw)
To: 'Bart Schaefer', zsh-workers
> schaefer<502> print "${foo:-"}"
> dquote braceparam>
>
> At this point the parser is in an infinite loop. There's nothing you
can
> type (except end-of-file or interrupt) that will free you from the PS2
> prompt.
>
Shell should not hang, but please note it is invalid as per POSIX.
Double-quotes and braces must match. So whatever fix is used, it should
not make the above valid construct (i.e. it should not print `"').
-andrej
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Quoted parameter parsing glitch
2001-08-22 16:21 ` Borsenkow Andrej
@ 2001-08-22 16:59 ` Bart Schaefer
2001-08-22 18:25 ` Borsenkow Andrej
0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2001-08-22 16:59 UTC (permalink / raw)
To: Borsenkow Andrej, zsh-workers
On Aug 22, 8:21pm, Borsenkow Andrej wrote:
} Subject: RE: Quoted parameter parsing glitch
}
} > schaefer<502> print "${foo:-"}"
} > dquote braceparam>
} >
} > At this point the parser is in an infinite loop.
I'm wrong, it's either more complicated than that example shows or it's
just me. It's possible to get out of that one by just:
schaefer<502> print "${foo:-"}"
dquote braceparam> }
dquote> "
}
schaefer<503>
I'm pretty sure I did manage to get it stuck on a more complicated
substitution, but my attempt to produce a minimal example went astray,
and I haven't reproduced whatever it was I first did.
} Shell should not hang, but please note it is invalid as per POSIX.
} Double-quotes and braces must match.
Zsh 4 (and ksh) is supposed to accept double-quotes inside ${...} inside
double-quotes; the braces act as an extra level of quoting so that the
inner quotes can nest in the outer ones. I don't know what POSIX says
about that.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Quoted parameter parsing glitch
2001-08-22 16:59 ` Bart Schaefer
@ 2001-08-22 18:25 ` Borsenkow Andrej
2001-08-26 17:26 ` Bart Schaefer
0 siblings, 1 reply; 7+ messages in thread
From: Borsenkow Andrej @ 2001-08-22 18:25 UTC (permalink / raw)
To: Bart Schaefer; +Cc: zsh-workers
On Wed, 22 Aug 2001, Bart Schaefer wrote:
>
> } Shell should not hang, but please note it is invalid as per POSIX.
> } Double-quotes and braces must match.
>
> Zsh 4 (and ksh) is supposed to accept double-quotes inside ${...} inside
> double-quotes; the braces act as an extra level of quoting so that the
> inner quotes can nest in the outer ones. I don't know what POSIX says
> about that.
>
As I said - they must match. "${foo:-""}" is valid but "${foo:-"}" - not.
Neither is "${foo:-\"}". You cannot quote braces or double quotes in this
case. They must match (opening - closing).
-andrej
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Quoted parameter parsing glitch
2001-08-22 18:25 ` Borsenkow Andrej
@ 2001-08-26 17:26 ` Bart Schaefer
2001-08-26 17:59 ` Borsenkow Andrej
0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2001-08-26 17:26 UTC (permalink / raw)
To: Borsenkow Andrej; +Cc: zsh-workers
On Aug 22, 10:25pm, Borsenkow Andrej wrote:
}
} As I said - they must match. "${foo:-""}" is valid but "${foo:-"}" - not.
The question is whether "${foo:-"}"}" is valid.
Also, the PS2 prompt doesn't know about nested double quotes. This is
probably what had me confused before:
schaefer<502> echo "${foo:-"}
dquote braceparam>
Note that the prompt indicates that `}"' will end the quoting scope, but
in fact you need `"}"'. The prompt should say
dquote braceparam dquote>
and does with the patch below.
Index: Src/lex.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/lex.c,v
retrieving revision 1.3
diff -c -r1.3 lex.c
--- Src/lex.c 2001/04/23 15:35:41 1.3
+++ Src/lex.c 2001/08/26 17:22:15
@@ -1395,7 +1395,9 @@
break;
if (bct) {
add(Dnull);
+ cmdpush(CS_DQUOTE);
err = dquote_parse('"', sub);
+ cmdpop();
c = Dnull;
} else
err = 1;
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2001-08-27 7:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-22 15:54 Quoted parameter parsing glitch Bart Schaefer
2001-08-22 16:21 ` Borsenkow Andrej
2001-08-22 16:59 ` Bart Schaefer
2001-08-22 18:25 ` Borsenkow Andrej
2001-08-26 17:26 ` Bart Schaefer
2001-08-26 17:59 ` Borsenkow Andrej
2001-08-27 7:22 ` 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).