help-bash
[Top][All Lists]
Advanced

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

Re: The difference between `X=x f | cat` and `{ X=x; f; } | cat`


From: Greg Wooledge
Subject: Re: The difference between `X=x f | cat` and `{ X=x; f; } | cat`
Date: Thu, 19 Jan 2023 10:53:42 -0500

On Thu, Jan 19, 2023 at 03:49:06PM +0000, Kerin Millar wrote:
> time for ((i=0; i < 1000; i++)); do X=x f | cat >/dev/null; done
> time for ((i=0; i < 1000; i++)); do { X=x; f; } | cat >/dev/null; done
> 
> Obviously, you may need to tune the number of iterations in order to incur an 
> acceptably substantive wall time.

I'd also move the >/dev/null outside the loop.  You're adding 1000x
the number of times it takes to make that system call to the execution
times, which might distort things a tiny bit.

Timing aside, "one of them makes X an environment variable and the
other doesn't" was already a sufficient answer to "are these the same".
Everything after that has been silliness.



reply via email to

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