Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH?] The here-doc that never ends
- X-seq: zsh-workers 50341
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [PATCH?] The here-doc that never ends
- Date: Mon, 6 Jun 2022 22:31:55 -0700
- Archived-at: <https://zsh.org/workers/50341>
- List-id: <zsh-workers.zsh.org>
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author