[Top][All Lists]

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

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

From: Eli Schwartz
Subject: Re: Undocumented feature: Unnamed fifo '<(:)'
Date: Sun, 28 Jun 2020 17:27:47 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

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

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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