summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-11-20 11:54:00 +0000
committerPádraig Brady <P@draigBrady.com>2015-11-21 16:45:18 +0000
commitc7f049c503527c3dd64b2850e2e768bbcf26f2a8 (patch)
treed04b7def991ad5993eb2d2795e1ec07912e73bfe /doc
parent56d3269207db13b0f3a594d6d2cbc52913929d21 (diff)
downloadcoreutils-c7f049c503527c3dd64b2850e2e768bbcf26f2a8.tar.xz
doc: give a tee example for combining process substitution outputs
This can be useful if you want to further process data from process substitutions. For example: datagen | tee >(md5sum --tag) > >(sha256sum --tag) | sort * doc/coreutils.texi (tee invocation): Mention that -p is useful with pipes that may not consume all data. Add an example, similar to the one above. * THANKS.in: Add Jirka Hladky.
Diffstat (limited to 'doc')
-rw-r--r--doc/coreutils.texi16
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 8034807a4..0e28f4971 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -13019,6 +13019,11 @@ so it works with @command{zsh}, @command{bash}, and @command{ksh},
but not with @command{/bin/sh}. So if you write code like this
in a shell script, be sure to start the script with @samp{#!/bin/bash}.
+Note also that if any of the process substitutions (or piped stdout)
+might exit early without consuming all the data, the @option{-p} option
+is needed to allow @command{tee} to continue to process the input
+to any remaining outputs.
+
Since the above example writes to one file and one process,
a more conventional and portable use of @command{tee} is even better:
@@ -13087,6 +13092,17 @@ tar chof - "$tardir" \
| bzip2 -9 -c > your-pkg-M.N.tar.bz2
@end example
+If you want to further process the output from process substitutions,
+and those processes write atomically (i.e., write less than the system's
+PIPE_BUF size at a time), that's possible with a construct like:
+
+@example
+tardir=your-pkg-M.N
+tar chof - "$tardir" \
+ | tee >(md5sum --tag) > >(sha256sum --tag) \
+ | sort | gpg --clearsign > your-pkg-M.N.tar.sig
+@end example
+
@exitstatus