2 ms·
> Getting anything out of a subshell that isn't from STDOUT is impossible. You can use I/O redirection with arbitrary file descriptor numbers, and you can let
by cryptonector 5y ago
> Getting anything out of a subshell that isn't from STDOUT is impossible.
You can use I/O redirection with arbitrary file descriptor numbers, and you can let the shell pick them. So you can `mknod` a pipe, `exec {pipefd_rw}<>"$pipe_name" {pipefd_ro}<"$pipe_name" {pipefd_rw}>"$pipe_name";` and now you have three open file descriptors that you can let the sub-shell use to communicate with the parent. And so you're not limited to stdin/stdout. I do wish there was a built-in for making an anonymous pipe instead of having to make one on filesystem.
(You have to open the named pipe for read-write first because otherwise you'll block, but if you don't want a read-write FD for it you can close it after opening the read and write FDs.)