zsh-workers
 help / color / mirror / code / Atom feed
* Expected behavior of background jobs in ${ ... }
@ 2023-10-03  0:48 Bart Schaefer
  2023-10-03  3:26 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2023-10-03  0:48 UTC (permalink / raw)
  To: Zsh hackers list

Consider:

echo ${ { sleep 10; echo foo; } & { sleep 5; echo bar; } & echo done; }

The only version of ksh I can conveniently test, discards the output
of the background jobs and substitutes only "done".  This is in
conflict with $( ... ) which delays for 10 seconds and then
substitutes "done bar foo".

It is conceivably possible to keep track of jobs started during the ${
... } substitution and force the shell to wait for them, but then
there's this case:

echo ${ { echo foo; } & { echo bar; } & echo done; }

Here ksh also discards the output of the background jobs and
substitutes only "done", but that may be an order of operations thing.
The current zsh implementation substitutes

foo
bar
done

but that's likely nondeterministic.

Is this worth worrying about?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Expected behavior of background jobs in ${ ... }
  2023-10-03  0:48 Expected behavior of background jobs in ${ ... } Bart Schaefer
@ 2023-10-03  3:26 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2023-10-03  3:26 UTC (permalink / raw)
  To: Zsh hackers list

On Mon, Oct 2, 2023 at 5:48 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> echo ${ { echo foo; } & { echo bar; } & echo done; }
>
> Here ksh also discards the output of the background jobs and
> substitutes only "done", but that may be an order of operations thing.

Yep:

$ echo ${ { echo foo; } & { echo bar; } & sleep 3; echo done; }
[1]    293173
[2]    293174
foo bar done


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-03  3:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-03  0:48 Expected behavior of background jobs in ${ ... } Bart Schaefer
2023-10-03  3:26 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).