Skip to content

Commit

Permalink
unexpand: tweak usage string (#906)
Browse files Browse the repository at this point in the history
* When specifying multiple tabstops separated by commas, spaces are not allowed after the comma
* Remove spaces after comma from usage string to avoid confusion
* Also remove redundant copy of ARGV as done in expand commit d2196f9
  • Loading branch information
mknos authored Jan 6, 2025
1 parent c2521ec commit b00fb53
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions bin/unexpand
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ my $Program = basename($0);
my $tabstop = 8;
my $opt_a = 0;
my @tabstops;
my @files;

while (@ARGV && $ARGV[0] =~ /\A\-(.+)/) {
my $val = $1;
Expand All @@ -53,12 +52,11 @@ while (@ARGV && $ARGV[0] =~ /\A\-(.+)/) {
}
shift @ARGV;
}
@files = @ARGV;

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

for my $file (@files) {
for my $file (@ARGV) {
my $in;
unless (open $in, '<', $file) {
warn "$Program: couldn't open '$file' for reading: $!'\n";
Expand All @@ -69,15 +67,15 @@ for my $file (@files) {
}
close $in;
}
unless (@files) {
unless (@ARGV) {
while (<>) {
unexpand_line($_);
}
}
exit EX_SUCCESS;

sub usage {
warn "usage: $Program [-a] [-tabstop] [-tab1, tab2, ...] [file ...]\n";
warn "usage: $Program [-a] [-tabstop] [-tab1,tab2,...] [file ...]\n";
exit EX_FAILURE;
}

Expand Down Expand Up @@ -128,7 +126,7 @@ unexpand - convert spaces to tabs
=head1 SYNOPSIS
unexpand [B<-a>] [B<-tabstop>] [B<-tab1, tab2, ...>] [B<file> ...]
unexpand [B<-a>] [B<-tabstop>] [B<-tab1,tab2,...>] [B<file> ...]
=head1 DESCRIPTION
Expand Down

0 comments on commit b00fb53

Please sign in to comment.