zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH?] The here-doc that never ends
@ 2022-06-07  5:31 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2022-06-07  5:31 UTC (permalink / raw)
  To: Zsh hackers list

zsh -f

% true << (
>

Note the shell is now at a PS2 prompt.  The only way to escape the PS2
prompt is to type a closing paren, at which point you're at

heredoc>

But then gethere() is waiting for a single line consisting of the C
string "(\n)" which it is not possible to enter.  The only way out is
to interrupt.

Brute-force patch for this is below, but it seems like we should be
able to catch it sooner?  This appears to arise only because zsh
accepts <<(command) as well as < <(command) (note spacing).

Same effect with:

% true <<$'\n'

but there doesn't seem to be any good way to prevent that, and bash
5.0.17 behaves the same in that case.

diff --git a/Src/parse.c b/Src/parse.c
index d612b7e17..5054e59d5 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2248,6 +2248,9 @@ par_redir(int *rp, char *idstring)
     struct heredocs **hd;
     int htype = type;

+    if (strchr(tokstr, '\n'))
+        YYERROR(ecused);
+
     /*
      * Add two here for the string to remember the HERE
      * terminator in raw and munged form.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-07  5:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-07  5:31 [PATCH?] The here-doc that never ends 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).