Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: The elements of enlightenment



On Tue, Dec 6, 2022 at 12:53 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> I hafta wonder why this forking is so necessary.

It's necessary because it's user-visible. Some code relies on the PID
within $(...) to be different from the parent. This is mostly relevant
for signals. In addition, changes to parameters and other shell state
within $(...) have no effect on the parent shell, which doesn't
necessarily require forking but is made easier by it.

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. The main
thread would be blocked on reading from the pipe until all commands
are executed.

Roman.




Messages sorted by: Reverse Date, Date, Thread, Author