From 3328ccd1174b3d6161d67fdb13a5be4e42808269 Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Wed, 15 Nov 2023 12:37:14 +0800 Subject: [PATCH] expand: read stdin * POD text mentions that reading standard input is supported * Behave like OpenBSD expand: stdin is implied if no files are given * Remove POD text specific to unexpand; doesn't belong here * Now the following are equivalent on my system... cat ar | perl expand - | md5sum cat ar | perl expand | md5sum perl expand ar | md5sum --- bin/expand | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/bin/expand b/bin/expand index a6ebd1c1..8717b3aa 100755 --- a/bin/expand +++ b/bin/expand @@ -41,7 +41,6 @@ EOF exit $_[0]; } -usage(1) unless scalar @ARGV > 0; usage(0) if grep /^-h$/, @ARGV; # at most one argument @@ -114,6 +113,9 @@ for my $file (@files) { close IN; } +unless (@files) { + do_expand ; +} __END__ @@ -125,9 +127,6 @@ expand - convert tabs to spaces expand [B<-h>] [B<-tabstop>] [B<-tab1, tab2, ...>] [B ...] -unexpand [B<-h>] [B<-a>] [B<-tabstop>] [B<-tab1, tab2, ...>] -[B ...] - =head1 DESCRIPTION I processes the named files or the standard input writing the @@ -140,10 +139,7 @@ If a single B argument is given, tabs are set B spaces apart instead of the default 8. If multiple tabstops are given then 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): +=head1 OPTIONS =over 4 @@ -153,19 +149,6 @@ Print a usage message and exit with a status code indicating success. =back -Option (with I only): - -=over 4 - -=item -a - -By default, only leading blanks and tabs are reconverted to maximal -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. - -=back - =head1 AUTHOR =for html