Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tee: remove -u option #685

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 43 additions & 3 deletions bin/tee
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ use strict;
use Getopt::Std qw(getopts);
use IO::File;

our $VERSION = '1.0';

my %opt;
getopts('aiu', \%opt) or die "usage: tee [-aiu] [file ...]\n";
getopts('ai', \%opt) or die "usage: tee [-ai] [file ...]\n";
$SIG{'INT'} = 'IGNORE' if $opt{'i'};
$| = 1 if $opt{'u'};
$| = 1;

my $mode = $opt{'a'} ? 'a' : 'w';
my $status = 0;
Expand All @@ -47,7 +49,7 @@ for (@ARGV) {
$status++;
next;
}
select((select($fh), $| = 1)[0]) if $opt{'u'};
select((select($fh), $| = 1)[0]);
my $fd = fileno($fh);
$fh{$fd}->{'name'} = $_;
$fh{$fd}->{'fh'} = $fh;
Expand All @@ -70,8 +72,46 @@ sub get_filehandles {
return @handles;
}

sub VERSION_MESSAGE {
print "tee version $VERSION\n";
exit 0;
}

__END__

=encoding utf8

=head1 NAME

tee - pipe fitting

=head1 SYNOPSIS

tee [-ai] [file ...]

=head1 DESCRIPTION

tee reads data from standard input, copying it to standard output
and to any files given as arguments. If no file arguments are provided,
tee behaves like the cat utility and copies only to standard output.
Files are opened in write mode by default, and output is not buffered.

=head2 OPTIONS

The following options are available:

=over 4

=item -a

Append output to the files instead of overwriting them

=item -i

Ignore the SIGINT signal

=back

=head1 EXIT STATUS

tee exits 0 on success, and >0 to indicate an error
Loading