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

Re: subprocess

On Mon, Jun 8, 2020 at 7:22 AM Pier Paolo Grassi <pierpaolog@xxxxxxxxx> wrote:
> What would be the best way to learn more about these mechanisms without
> digging in the source code of the shell or the kernel?

Hmm.  Digging in the source code probably isn't the best way even if
you were interested.  It's a tough question.

This is all documented, but not in any single coherent place, mostly
because there are just too many possible ways to combine things to
explain all the variations.  For example the closing of all
descriptors >= 10 when starting a new job is long-standing,
standardized shell behavior, so the zsh manual doesn't mention it,
you're just expected to have learned (elsewhere) that is how shells
work.  I'm not sure the "named functions get their own job" part is
explained very clearly anywhere, but it is explained that anonymous
functions do not behave that way.  (E.g., "Redirections may be applied
to the anonymous function in the same manner as to a current-shell
structure enclosed in braces.")  It's explained that <(...) uses a
special file representing a file descriptor ("If the system supports
the /dev/fd mechanism, the command argument is the name of the device
file corresponding to a file descriptor" -- that should probably
mention /proc/self/fd as well) but does not warn that it might
conflict with the "close all descriptors above 10" behavior.

The upshot is that the best way to learn is probably to ask somebody.
I don't think all these sorts of nuances are even covered by most
books on shell programming.

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