Skip to content

Commit

Permalink
pr: fail for -3x option
Browse files Browse the repository at this point in the history
* GNU pr and OpenBSD pr read option -3x as -3 -x
* An error is raised because -x is not a valid option
* This version was incorrectly absorbing non-digits after the "-3"
* Removing the dot-match makes this version consistent
* redo statement allows -x to be interpreted as the next option after $columns is set to 3
  • Loading branch information
mknos authored Dec 29, 2023
1 parent 0c1db82 commit ac16a38
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bin/pr
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ while (@ARGV && $ARGV[0] =~ /^-(.+)/ && (shift, ($_ = $1), 1)) {
}

# Accept -2, -3, etc...
if (s/^(\d.*)//) {
if (s/\A([0-9]+)//) {
$columns = $1;
next OPTION;
redo OPTION;
}

usage("unexpected option: -$_");
Expand Down

0 comments on commit ac16a38

Please sign in to comment.