Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16476

Re: Undocumented feature: Unnamed fifo '<(:)'

From Eli Schwartz <eschwartz@archlinux.org>
Newsgroups gnu.bash.bug
Subject Re: Undocumented feature: Unnamed fifo '<(:)'
Date 2020-06-28 17:27 -0400
Message-ID <mailman.596.1593379681.2574.bug-bash@gnu.org> (permalink)
References <d1172623-25cb-bcf9-b9b5-b7bf3cb547f7@archlinux.org> <20200628134945.GB24863@medium.hauri> <CANaoh6KSJS8X73Zqj7M8TT6_gAOjGraZx1EaEVwUNN_=Yya3wQ@mail.gmail.com> <6427.1593375682@jinx.noi.kre.to> <346bda2f-83dc-afda-d911-9688daefb10e@archlinux.org>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 6/28/20 4:21 PM, Robert Elz wrote:
> I noticed that explanation, but like Dennis, I fail to see how the
> complicated version does any more than pretend there are less forks
> happening.   Was the speed of this actually measured, and if so, where
> are the comparative results?

Sure, and that can be pointed out, but that's a long way away from what
Dennis actually said, which is "why not just use a function", implying
that the use or not of a function is relevant here.

> Either way, to make the conversion, the date command needs to be run
> (in the complicated version, setbuf as well, which means an extra exec
> at least) - running a command means a fork, and all we have to start
> with is bash, so bash needs to fork to run date, each time it needs
> to run.
> 
> What evidence is there that the complicated way, with all of its extra
> file opens, etc, is faster than the simple way, or involves less forks?

IIRC bash will (if it can) optimize out $(cmd) to fork+exec cmd, rather
than fork bash, then fork+exec cmd. Perhaps the OP is assuming that the
fifo dance will result in one fork, rather than two?

Pointing out this flawed assumption is a useful data point, saying "why
not just use a function" is not. (In fact, I'd assume the $(function) is
actively a bad idea as it would prevent bash from optimizing out the
$(/usr/bin/date) fork.)

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Undocumented feature: Unnamed fifo '<(:)' Eli Schwartz <eschwartz@archlinux.org> - 2020-06-28 17:27 -0400

csiph-web