bug-bash
[Top][All Lists]
Advanced

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

Re: [PATCH] Add shopts for trailing newlines in command substitution and


From: Oğuz
Subject: Re: [PATCH] Add shopts for trailing newlines in command substitution and here strings
Date: Wed, 27 Aug 2025 11:40:58 +0300

On Wednesday, August 27, 2025, Kevin Pulo <kevin.pulo@mongodb.com> wrote:

> I would still have to tell people
> "don't use $(), always do some_command > $tmpfile", which isn't much better
> than what I'm trying to avoid ("don't use $(), always use shopt -o
> lastpipe and
> do some_command | grab_output varname").  It's also counter-intuitive to
> read
> instructions which say "redirect to a file and then inspect the file is
> okay,
> but capturing output via $() and then inspecting it isn't okay".
>
> It's still awkward to inspect the $tmpfile (at least within the shell),
> because
> the natural way to do that is $(<$tmpfile)... which still eats the trailing
> newlines.  Meaning I would be back to doing things like read -rd '', which
> even
> if hidden inside a grab_output style helper, isn't idiomatic.
>
> Lesser concerns are that it also assumes a writable $TMPDIR, and the extra
> filesystem involvement can affect performance.
>

Hmm. How much control do you have on the input format? If it's not too
late, rather than swimming against the current maybe you should alter the
input so it can be easily parsed by a POSIX shell


-- 
Oğuz


reply via email to

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