Skip to content

Commit 4d08c59

Browse files
authored
chmod: show which option is wrong (#982)
* The supported options are -R/-L/-H/-P, and grouping of options is allowed (e.g. -LP) * When adding an unexpected option letter to a group, the error message was misleading * "perl chmod -Rp" reported "invalid option -- pR", but R is a valid option * Fix this by validation the option letters after the option string has been split into a single letters
1 parent b30249e commit 4d08c59

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bin/chmod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ while (@ARGV && $ARGV [0] =~ /^-/) {
3030
my $opt = reverse shift;
3131
chop $opt;
3232
last if ($opt eq '-');
33-
unless ($opt =~ /^[RHLP]+$/) {
34-
warn "$Program: invalid option -- $opt\n";
35-
usage();
36-
}
3733
local $_;
3834
while (length ($_ = chop $opt)) {
35+
unless (m/\A[RHLP]\Z/) {
36+
warn "$Program: invalid option -- '$_'\n";
37+
usage();
38+
}
3939
/R/ && do {$options {R} = 1; next};
4040
usage() unless $options{'R'};
4141
/H/ && do {$options {L} = $options {P} = 0; $options {H} = 1; next};

0 commit comments

Comments
 (0)