From b3e763cc228b182019c22a3490312f7b17df4029 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Wed, 24 Jan 2024 17:56:21 -0800 Subject: 52482: strip trailing newlines in emulation modes of ${ command; } --- Src/subst.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Src/subst.c') diff --git a/Src/subst.c b/Src/subst.c index 3a1187350..650c09de2 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -2005,6 +2005,12 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, int onoerrs = noerrs, rplylen; noerrs = 2; rplylen = zstuff(&cmdarg, rplytmp); + if (! EMULATION(EMULATE_ZSH)) { + /* bash and ksh strip trailing newlines here */ + while (rplylen > 0 && cmdarg[rplylen-1] == '\n') + rplylen--; + cmdarg[rplylen] = 0; + } noerrs = onoerrs; if (rplylen >= 0) setsparam("REPLY", metafy(cmdarg, rplylen, META_REALLOC)); -- cgit 1.4.1