Skip to content

Commit

Permalink
expand: '--' option terminator (#492)
Browse files Browse the repository at this point in the history
* Accept usage that GNU expand accepts: "perl expand -4 -- -a" for a file called "-a"
* Remove stray quote from error string
  • Loading branch information
mknos committed Mar 11, 2024
1 parent b931b27 commit f0fbf8a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bin/expand
Expand Up @@ -39,9 +39,13 @@ my $tabstop = 8;
my @tabstops;
my @files;

# at most one argument
if ($ARGV[0] =~ /\A\-(.+)/) {
@tabstops = split(/,/, $1);
while (@ARGV && $ARGV[0] =~ /\A\-(.+)/) {
my $val = $1;
if ($val eq '-') {
shift @ARGV;
last;
}
@tabstops = split /,/, $val;
usage(1) if grep /\D/, @tabstops; # only integer arguments are allowed
shift @ARGV;
}
Expand All @@ -67,7 +71,7 @@ if(scalar @tabstops == 0) {
for my $file (@files) {
my $in;
unless (open $in, '<', $file) {
warn "$Program: couldn't open '$file' for reading: $!'\n";
warn "$Program: couldn't open '$file' for reading: $!\n";
exit EX_FAILURE;
}
while (<$in>) {
Expand Down

0 comments on commit f0fbf8a

Please sign in to comment.