From d7b8619396d806d390126c2abd1c3ce099fe7f59 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Tue, 8 Mar 2022 19:34:20 +0100 Subject: 49813: <<<: Document newline behavior and fix optimization The =(<< * 49918: NEWS, README: Update for 49917 and 49911. diff --git a/Doc/Zsh/redirect.yo b/Doc/Zsh/redirect.yo index 2b48974b4..fd40ab5a4 100644 --- a/Doc/Zsh/redirect.yo +++ b/Doc/Zsh/redirect.yo @@ -86,7 +86,8 @@ item(tt(<<<) var(word))( Perform shell expansion on var(word) and pass the result to standard input. This is known as a em(here-string). Compare the use of var(word) in here-documents above, where var(word) -does not undergo shell expansion. +does not undergo shell expansion. The result will have a trailing newline +after it. ) xitem(tt(<&) var(number)) item(tt(>&) var(number))( diff --git a/Src/exec.c b/Src/exec.c index f67074846..70cbfc97f 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -4836,8 +4836,10 @@ getoutputfile(char *cmd, char **eptr) singsub(&s); if (errflag) s = NULL; - else + else { untokenize(s); + s = dyncat(s, "\n"); + } } if (!s) /* Unclear why we need to do this before open() */ -- cgit 1.4.1