summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-02-16 12:55:40 +0000
committerPádraig Brady <P@draigBrady.com>2015-02-24 18:12:22 +0000
commitfdd6ebf0ae786681e99afdaf1ef44bb750e66b2d (patch)
tree522b47c895184ea102345caa3bbea280dd223255 /doc
parent19d34d244b46227e83ec43969f99c5e3b23ea01d (diff)
downloadcoreutils-fdd6ebf0ae786681e99afdaf1ef44bb750e66b2d.tar.xz
tee: add --write-error to control handling of closed pipes
tee is very often used with pipes and this gives better control when writing to them. There are 3 classes of file descriptors that tee can write to: files(1), pipes(2), and early close pipes(3). Handling write errors to 1 & 2 is supported at present with the caveat that failure writing to any pipe will terminate tee immediately. Handling write errors to type 3 is not currently supported. To improve the supported combinations we add these options: --write-error=warn Warn if error writing any output including pipes. Allows continued writing to still open files/pipes. Exit status is failure if any output had error. --write-error=warn-nopipe, -p Warn if error writing any output except pipes. Allows continued writing to still open files/pipes. Exit status is failure if any non pipe output had error. --write-error=exit Exit if error writing any output including pipes. --write-error=exit-nopipe Exit if error writing any output except pipes. Use the "nopipe" variants when files are of types 1 and 3, otherwise use the standard variants with types 1 and 2. A caveat with the above scheme is that a combination of pipe types (2 & 3) is not supported robustly. I.e. if you use the "nopipe" variants when using both type 2 and 3 pipes, then any "real" errors on type 2 pipes will not be diagnosed. Note also a general issue with type 3 pipes that are not on tee's stdout, is that shell constructs don't allow to distinguish early close from real failures. For example `tee >(head -n1) | grep -m1 ..` can't distinguish between an error or an early close in "head" pipe, while the fail on the grep part of the pipe is distinguished independently from the resulting pipe errors. This is a general issue with the >() construct, rather than with tee itself. * NEWS: Mention the new feature. * doc/coreutils.texi (tee invocation): Describe the new option. * src/tee.c (usage): Likewise. (main): With --write-error ignore SIGPIPE, and handle the various exit, diagnostics combinations. * tests/misc/tee.sh: Tess all the new options. Fixes http://bugs.gnu.org/11540
Diffstat (limited to 'doc')
-rw-r--r--doc/coreutils.texi26
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 8d050c2e8..d3239a567 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -13201,6 +13201,32 @@ them.
@opindex --ignore-interrupts
Ignore interrupt signals.
+@item -p
+@itemx --write-error[=@var{mode}]
+@opindex -p
+@opindex --write-error
+Select the behavior with write errors on the outputs,
+where @var{mode} is one of the following:
+
+@table @samp
+@item warn
+Warn on error writing any output, including pipes.
+Writing is continued to still open files/pipes.
+Exit status indicates failure if any output has an error.
+
+@item warn-nopipe
+Warn on error writing any output, except pipes.
+Writing is continued to still open files/pipes.
+Exit status indicates failure if any non pipe output had an error.
+This is the default @var{mode} when not specified.
+
+@item exit
+Exit on error writing any output, including pipes.
+
+@item exit-nopipe
+Exit on error writing any output, except pipes.
+@end table
+
@end table
The @command{tee} command is useful when you happen to be transferring a large