|
2 | 2 |
|
3 | 3 | \subsection psub-synopsis Synopsis |
4 | 4 | \fish{synopsis} |
5 | | -COMMAND1 ( COMMAND2 | psub [-f] [-s SUFFIX]) |
| 5 | +COMMAND1 ( COMMAND2 | psub [-F | --fifo] [-f | --file] [-s SUFFIX]) |
6 | 6 | \endfish |
7 | 7 |
|
8 | 8 | \subsection psub-description Description |
9 | 9 |
|
10 | | -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. |
| 10 | +Some shells (e.g., ksh, bash) 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. |
11 | 11 |
|
12 | | -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. |
| 12 | +The following options are available: |
13 | 13 |
|
14 | | -If the `-s` or `---suffix` switch is given, `psub` will append SUFFIX to the filename. |
| 14 | +- `-f` or `--file` will cause psub to 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. This is the default. |
15 | 15 |
|
| 16 | +- `-F` or `--fifo` will cause psub to use a named pipe rather than a file. You should only use this if the command produces no more than 8 KiB of output. The limit on the amount of data a FIFO can buffer varies with the OS but is typically 8 KiB, 16 KiB or 64 KiB. If you use this option and the command on the left of the psub pipeline produces more output a deadlock is likely to occur. |
| 17 | + |
| 18 | +- `-s` or `--suffix` will append SUFFIX to the filename. |
16 | 19 |
|
17 | 20 | \subsection psub-example Example |
18 | 21 |
|
19 | 22 | \fish |
20 | 23 | diff (sort a.txt | psub) (sort b.txt | psub) |
21 | 24 | # shows the difference between the sorted versions of files `a.txt` and `b.txt`. |
22 | 25 |
|
23 | | -source-highlight -f esc (cpp main.c | psub -s .c) |
| 26 | +source-highlight -f esc (cpp main.c | psub -f -s .c) |
24 | 27 | # highlights `main.c` after preprocessing as a C source. |
25 | 28 | \endfish |
0 commit comments