Skip to content

Commit 6d25a72

Browse files
authored
tee: remove -u option (#685)
* The standard tee writes output in unbuffered mode by default, so the -u option is not needed * The code guarded by $opt{'u'} now happens unconditionally * Introduce $VERSION and make the --version option work * Add some basic content for the manual
1 parent fa32a1e commit 6d25a72

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

bin/tee

+43-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ use strict;
2222
use Getopt::Std qw(getopts);
2323
use IO::File;
2424

25+
our $VERSION = '1.0';
26+
2527
my %opt;
26-
getopts('aiu', \%opt) or die "usage: tee [-aiu] [file ...]\n";
28+
getopts('ai', \%opt) or die "usage: tee [-ai] [file ...]\n";
2729
$SIG{'INT'} = 'IGNORE' if $opt{'i'};
28-
$| = 1 if $opt{'u'};
30+
$| = 1;
2931

3032
my $mode = $opt{'a'} ? 'a' : 'w';
3133
my $status = 0;
@@ -47,7 +49,7 @@ for (@ARGV) {
4749
$status++;
4850
next;
4951
}
50-
select((select($fh), $| = 1)[0]) if $opt{'u'};
52+
select((select($fh), $| = 1)[0]);
5153
my $fd = fileno($fh);
5254
$fh{$fd}->{'name'} = $_;
5355
$fh{$fd}->{'fh'} = $fh;
@@ -70,8 +72,46 @@ sub get_filehandles {
7072
return @handles;
7173
}
7274

75+
sub VERSION_MESSAGE {
76+
print "tee version $VERSION\n";
77+
exit 0;
78+
}
79+
80+
__END__
81+
7382
=encoding utf8
7483
7584
=head1 NAME
7685
7786
tee - pipe fitting
87+
88+
=head1 SYNOPSIS
89+
90+
tee [-ai] [file ...]
91+
92+
=head1 DESCRIPTION
93+
94+
tee reads data from standard input, copying it to standard output
95+
and to any files given as arguments. If no file arguments are provided,
96+
tee behaves like the cat utility and copies only to standard output.
97+
Files are opened in write mode by default, and output is not buffered.
98+
99+
=head2 OPTIONS
100+
101+
The following options are available:
102+
103+
=over 4
104+
105+
=item -a
106+
107+
Append output to the files instead of overwriting them
108+
109+
=item -i
110+
111+
Ignore the SIGINT signal
112+
113+
=back
114+
115+
=head1 EXIT STATUS
116+
117+
tee exits 0 on success, and >0 to indicate an error

0 commit comments

Comments
 (0)