help / color / mirror / code / Atom feed
* Non-forking command substitution
       [not found]               ` <21586f92-9a78-419c-84e5-f203a6f069b6@app.fastmail.com>
@ 2022-12-07  0:46                 ` Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2022-12-07  0:46 UTC (permalink / raw)
  To: Zsh hackers list

Redirecting to zsh-workers.

On Tue, Dec 6, 2022 at 3:54 PM Lawrence Velázquez <larryv@zsh.org> wrote:
> On Tue, Dec 6, 2022, at 1:55 PM, Roman Perepelitsa wrote:
> > That said, it's totally possible to extend zsh with something like $[
> > ... ] which would work like $( ... ) but without forking. It would run
> > the commands in another thread within the same process.
> FWIW, ksh has a ${ list;} construct that avoids a subshell:

The "when followed by a space ${ starts a command, otherwise it's a
parameter reference" is a bit odd, but I guess not odder than some of
the things we do.

Based on some random poking at ksh93, this construct does two things:
1. Switches from fork-to-the-right (bash, older sh) behavior to
fork-to-the-left (zsh) behavior for pipes, so the rightmost part of a
pipeline may run in the current shell.
2. If the rightmost thing is a builtin, captures/substitutes its
output instead of printing it to stdout, otherwise acts exactly like

Neither of those things actually requires a separate thread, though it
does require some engineering down in the guts of builtin commands to
replace simple stdio handling.

It'd be interesting to know how ksh93 handles the ^Z/fg issues with
left-forking that were recounted in recent -workers discussion.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-07  0:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <54bcd6dd-e589-4696-f042-1155b78df9d2@eastlink.ca>
     [not found] ` <CAN=4vMp2r4Syu-CuF=gxed5om9JQ+NDQm6LvNZRBE4d5a4v1xw@mail.gmail.com>
     [not found]   ` <819c9630-f315-8b1c-cb52-3d3ae8de2d5c@eastlink.ca>
     [not found]     ` <CAN=4vMqKXudgwwQAPNzJ0OymhYWwPWu+ec+LyiVK2nhDP1jbeg@mail.gmail.com>
     [not found]       ` <7eadf163-da34-d90b-61ce-b527fb75b597@eastlink.ca>
     [not found]         ` <CAN=4vMq7=BGygpKU4ed_b33tdE0NGoCALZdaF10hz0co4zqksQ@mail.gmail.com>
     [not found]           ` <37b2456f-0459-4b85-74d1-bb380715e2ed@eastlink.ca>
     [not found]             ` <CAN=4vMp_LqvioJE_uW2_CwJ7CKL2dVwGn-6LMonPf_5pfngkzA@mail.gmail.com>
     [not found]               ` <21586f92-9a78-419c-84e5-f203a6f069b6@app.fastmail.com>
2022-12-07  0:46                 ` Non-forking command substitution Bart Schaefer

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


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).