<(commands ...) in bash/zsh makes the output behavior as a file.
Does a POSIX equivalent exist?
Asked
Active
Viewed 1,572 times
13
-
4[POSIX does not specify process substitution, but you may used named pipes to accomplish the same thing.](http://mywiki.wooledge.org/ProcessSubstitution) – bishop Aug 05 '16 at 19:09
-
Possible duplicate of [Is it possible to mimic process substitution on msys /mingw (with bash 3.x)](http://stackoverflow.com/questions/20866832/is-it-possible-to-mimic-process-substitution-on-msys-mingw-with-bash-3-x) – P.P Aug 05 '16 at 19:16
-
2@P.P., I'm not really fond of that specific potential dupe, inasmuch as it folds in some misconceptions (among them, that bash 3.x *doesn't* support process substitution; that's a msys restriction, as opposed to a version-based one). – Charles Duffy Aug 05 '16 at 19:22
1 Answers
14
mkfifo foo.fifo
## if your "commands" is multiple commands
# { commands ...; } >foo.fifo &
# otherwise, if it's just one
commands ... >foo.fifo &
something_else foo.fifo
is the closest available equivalent to
something_else <( commands ... )
Charles Duffy
- 257,635
- 38
- 339
- 400
-
Possible "robustness" improvements would be to use something like `mktemp` to generate a directory for one of more pipes safe from collisions (or just to generate a name to use for the pipe, since `mkfifo` is atomic), etc. In reality, that's all ` – mtraceur Sep 05 '16 at 07:52
-
2
-
-
1There's no POSIX way to do this because POSIX does not define `mktemp`. One either needs to reimplement `mktemp` with using only POSIX shell behavior or have to come up with some kind of hacks. – Mikko Rantalainen Apr 26 '20 at 11:56