dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug when parsing redirection syntax error
@ 2020-06-03 18:55 Matt Whitlock
  2020-06-04  3:56 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Whitlock @ 2020-06-03 18:55 UTC (permalink / raw)
  To: dash

$ cat <<<EOF
dash: 4: Syntax error: redirection unexpected
$ true
dash: 4: Etrue: not found

This is with Dash 0.5.11.

It looks like the first character after the unexpected redirection operator 
mistakenly gets retained in a buffer somewhere and interferes with the next 
command to be read.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug when parsing redirection syntax error
  2020-06-03 18:55 Bug when parsing redirection syntax error Matt Whitlock
@ 2020-06-04  3:56 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2020-06-04  3:56 UTC (permalink / raw)
  To: Matt Whitlock; +Cc: dash

Matt Whitlock <dash@mattwhitlock.name> wrote:
> $ cat <<<EOF
> dash: 4: Syntax error: redirection unexpected
> $ true
> dash: 4: Etrue: not found
> 
> This is with Dash 0.5.11.
> 
> It looks like the first character after the unexpected redirection operator 
> mistakenly gets retained in a buffer somewhere and interferes with the next 
> command to be read.

This is because dash needs to clear the unget buffer on reset.

Reported-by: Matt Whitlock <dash@mattwhitlock.name>
Fixes: 17db43b58415 ("input: Allow two consecutive calls to pungetc")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/src/input.c b/src/input.c
index 4987732..d7c101b 100644
--- a/src/input.c
+++ b/src/input.c
@@ -87,6 +87,7 @@ INIT {
 RESET {
 	/* clear input buffer */
 	basepf.lleft = basepf.nleft = 0;
+	basepf.unget = 0;
 	popallfiles();
 }
 
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-04  3:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 18:55 Bug when parsing redirection syntax error Matt Whitlock
2020-06-04  3:56 ` Herbert Xu

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).