From a68b510994b5d46b508df2ec4da0badd8cc893ff Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Wed, 15 Nov 2023 13:29:06 +0800 Subject: [PATCH] unexpand: read stdin * 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 --- bin/unexpand | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/bin/unexpand b/bin/unexpand index 5310bece..7f4116e5 100755 --- a/bin/unexpand +++ b/bin/unexpand @@ -42,7 +42,6 @@ EOF exit $_[0]; } -usage(1) unless scalar @ARGV > 0; usage(0) if grep {$_ eq "-h"} @ARGV; my $arg; @@ -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; @@ -111,6 +108,9 @@ for my $file (@files) { close IN; } +unless (@files) { + do_unexpand ; +} __END__ @@ -120,8 +120,6 @@ unexpand - convert spaces to tabs =head1 SYNOPSIS -expand [B<-h>] [B<-tabstop>] [B<-tab1, tab2, ...>] [B ...] - unexpand [B<-h>] [B<-a>] [B<-tabstop>] [B<-tab1, tab2, ...>] [B ...] @@ -140,17 +138,7 @@ the tabs are set at those specific columns. I 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 and I): - -=over 4 - -=item -h - -Print a usage message and exit with a status code indicating success. - -=back - -Option (with I only): +=head1 OPTIONS =over 4 @@ -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