Skip to content

Commit

Permalink
tee: expectation for -n option
Browse files Browse the repository at this point in the history
* This version of tee has a non-standard option -n to disable writing output to stdout
* When using -n without any file arguments, tee reads its input and does nothing
* Reading input has no effect so raise an error instead
* I'm happy to remove the -n option if you prefer
  • Loading branch information
mknos authored Sep 19, 2023
1 parent 6bb289f commit 9fed043
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bin/tee
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ if ($ignore_ints) {
$SIG{'PIPE'} = 'PLUMBER';
$mode = $append ? '>>' : '>';
$fh = 'FH000';
unless ($nostdout) {
if ($nostdout) {
unless (@ARGV) {
warn "$0: file argument must be given with -n\n";
exit 1;
}
} else {
%fh = ('STDOUT', 'standard output'); # always go to stdout
}
$| = 1 if $unbuffer;
Expand Down

0 comments on commit 9fed043

Please sign in to comment.