bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] command substitution with trailing newlines (was Re: [PATCH]


From: Chet Ramey
Subject: Re: [PATCH] command substitution with trailing newlines (was Re: [PATCH] Add shopts for ...)
Date: Fri, 5 Sep 2025 16:43:31 -0400
User-agent: Mozilla Thunderbird

On 8/29/25 7:15 AM, Kevin Pulo wrote:
On Fri, 29 Aug 2025 at 01:00, Koichi Murase <myoga.murase@gmail.com> wrote:

If the feature is really desired by the community as an essential feature, it
should be implemented as a new syntax.

I looked at adding alternate syntax for doing command substitution without
stripping trailing newlines, and it turned out to be easier than I expected.

This patch adds the syntax ${;cmd;}, which is handled identically to ${ cmd;}
except that trailing newlines are preserved.

I like this alternative. I considered $`command` but with no nofork
variant, but that might already exist in some script somewhere to
construct a variable name to be supplied to eval or similar.

I'm not wild about the choice of `;' but I don't think it's appreciably
worse than something like `${+cmd;}', other than being visually jarring.
Anyone else have candidates for the command character?

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]