Skip to content

Commit

Permalink
unexpand: read stdin
Browse files Browse the repository at this point in the history
* According to the standard it is valid for unexpand to be passed no file argument
* POD text mentions reading standard input is supported (SYNOPSIS also lists file as optional)
* Add OPTIONS section to POD and remove SYNOPSIS of expand
  • Loading branch information
mknos authored Nov 15, 2023
1 parent 5676921 commit a68b510
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions bin/unexpand
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ EOF
exit $_[0];
}

usage(1) unless scalar @ARGV > 0;
usage(0) if grep {$_ eq "-h"} @ARGV;

my $arg;
Expand All @@ -56,8 +55,6 @@ while($arg = shift @ARGV) {
push @files, $arg;
}

usage(1) unless scalar @files >= 0;

# $tabstop is used only if multiple tab stops have not been defined
$tabstop = $tabstops[0] if scalar @tabstops == 1;

Expand Down Expand Up @@ -111,6 +108,9 @@ for my $file (@files) {

close IN;
}
unless (@files) {
do_unexpand <STDIN>;
}

__END__
Expand All @@ -120,8 +120,6 @@ unexpand - convert spaces to tabs
=head1 SYNOPSIS
expand [B<-h>] [B<-tabstop>] [B<-tab1, tab2, ...>] [B<file> ...]
unexpand [B<-h>] [B<-a>] [B<-tabstop>] [B<-tab1, tab2, ...>]
[B<file> ...]
Expand All @@ -140,17 +138,7 @@ the tabs are set at those specific columns.
I<unexpand> puts tabs back into the data from the standard input or the
named files and writes the result on the standard output.
Option (with I<expand> and I<unexpand>):
=over 4
=item -h
Print a usage message and exit with a status code indicating success.
=back
Option (with I<unexpand> only):
=head1 OPTIONS
=over 4
Expand All @@ -161,6 +149,10 @@ strings of tabs. If the B<-a> option is given, tabs are inserted
whenever they would compress the resultant file by replacing two or
more characters.
=item -h
Print a usage message and exit with a status code indicating success.
=back
=head1 AUTHOR
Expand Down

0 comments on commit a68b510

Please sign in to comment.