From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8779 invoked by alias); 2 Sep 2015 13:14:40 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36399 Received: (qmail 10803 invoked from network); 2 Sep 2015 13:14:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f5-f794b6d000001495-3f-55e6f639d7f7 Date: Wed, 02 Sep 2015 14:13:54 +0100 From: Peter Stephenson To: zsh workers Subject: Re: Here document in code chunks Message-id: <20150902141354.48c4d872@pwslap01u.europe.root.pri> In-reply-to: <20150902100347.03027225@pwslap01u.europe.root.pri> References: <20150902100347.03027225@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCLMWRmVeSWpSXmKPExsVy+t/xK7qW356FGsxr4LY42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGUdPT2EuaOatOPSgg62BsZOri5GTQ0LAROL3kkNMELaYxIV7 69m6GLk4hASWMkosPbeDHcKZwSRxcOd0dpAqIYGtjBIHWlNBbBYBVYlZp5YygthsAoYSUzfN BrNFgOLN3/+xgNjCApoSn6ecB+vlFbCXeHe1CWwbp4CDxM33d6AWdDBKXDq1CSzBL6AvcfXv J6iT7CVmXjnDCNEsKPFj8j2wocwCWhKbtzWxQtjyEpvXvGWGOE5d4sbd3ewTGIVmIWmZhaRl FpKWBYzMqxhFU0uTC4qT0nON9IoTc4tL89L1kvNzNzFCwvbrDsalx6wOMQpwMCrx8DYkPgsV Yk0sK67MPcQowcGsJMKb8BIoxJuSWFmVWpQfX1Sak1p8iFGag0VJnHfmrvchQgLpiSWp2amp BalFMFkmDk6pBkbThQzPY+UOeUVmqNTHvAn4OUdW+MOOF49uhy1iOL9qXtNFuaM33D3v3vLa ckDu28+YwqIPSbN2lCd86Um8ePP7414//xmMp6JPb9IrVNxvVH/WTunObp0PvxYoaQfP50wI i599aU5pvJNwSdgS0WWbWALsjnFs/GdR7XtNWk/zX4ER5x+ZGE8lluKMREMt5qLiRAChRlzD VwIAAA== On Wed, 2 Sep 2015 10:03:47 +0100 Peter Stephenson wrote: > On Wed, 2 Sep 2015 10:50:07 +0200 > Mikael Magnusson wrote: >> % f() { cat << x << y; } >> foo >> x >> bar >> y >> % which f >> f () { >> cat <> foo >> xbar >> y >> } >> >> There should be a newline between x and bar in the output. The >> function itself works fine. It seems to be this simple. (Here, here.) pws diff --git a/Src/text.c b/Src/text.c index 3978a26..7e65f43 100644 --- a/Src/text.c +++ b/Src/text.c @@ -77,8 +77,8 @@ taddpending(char *str1, char *str2) */ if (tpending) { int oldlen = strlen(tpending); - tpending = zrealloc(tpending, len + oldlen); - sprintf(tpending + oldlen, "%s%s", str1, str2); + tpending = zrealloc(tpending, len + oldlen + 1); + sprintf(tpending + oldlen, "\n%s%s", str1, str2); } else { tpending = (char *)zalloc(len); sprintf(tpending, "%s%s", str1, str2); diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst index 602341d..d7fe22f 100644 --- a/Test/A04redirect.ztst +++ b/Test/A04redirect.ztst @@ -555,3 +555,34 @@ 0:Assignment with exec used for redirection: POSIX_BUILTINS >x=And this ?This should appear, too + + fn-two-heres() { +# tabs below + cat <<-x <<-y + foo + x + bar + y + } + which -x2 fn-two-heres + fn-two-heres + eval "$(which -x2 fn-two-heres)" + fn-two-heres + print $functions[fn-two-heres] +0:Two here-documents in a line are shown correctly. +>fn-two-heres () { +> cat <foo +>x +>bar +>y +>} +>foo +>bar +>foo +>bar +> cat <foo +>x +>bar +>y