fish-shell/doc_src/psub.txt

26 lines
1.3 KiB
Text
Raw Normal View History

\section psub psub - perform process substitution
\subsection psub-synopsis Synopsis
2014-08-01 12:25:41 +00:00
\fish{synopsis}
2015-02-16 12:28:11 +00:00
COMMAND1 ( COMMAND2 | psub [-f] [-s SUFFIX])
\endfish
\subsection psub-description Description
Posix shells feature a syntax that is a mix between command substitution and piping, called process substitution. It is used to send the output of a command into the calling command, much like command substitution, but with the difference that the output is not sent through commandline arguments but through a named pipe, with the filename of the named pipe sent as an argument to the calling program. `psub` combined with a regular command substitution provides the same functionality.
If the `-f` or `--file` switch is given to `psub`, `psub` will use a regular file instead of a named pipe to communicate with the calling process. This will cause `psub` to be significantly slower when large amounts of data are involved, but has the advantage that the reading process can seek in the stream.
2015-02-16 12:28:11 +00:00
If the `-s` or `---suffix` switch is given, `psub` will append SUFFIX to the filename.
\subsection psub-example Example
\fish
diff (sort a.txt | psub) (sort b.txt | psub)
# shows the difference between the sorted versions of files `a.txt` and `b.txt`.
2015-02-16 12:28:11 +00:00
source-highlight -f esc (cpp main.c | psub -s .c)
# highlights `main.c` after preprocessing as a C source.
\endfish