Skip to content

Commit

Permalink
which: expect an argument
Browse files Browse the repository at this point in the history
* Running "which" without an argument is an error (minimum of one argument is required)
* On my linux system, exit code is 1 and no output is printed
* On OpenBSD a usage string is printed; follow this
  • Loading branch information
mknos authored Dec 18, 2023
1 parent d8ab29f commit 235b6a0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bin/which
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ use constant EX_FAILURE => 1;
my $Program = basename($0);
my ($VERSION) = '1.3';

my %opt;
unless (getopts('a', \%opt)) {
sub usage {
warn "$Program version $VERSION\n";
warn "usage: $Program [-a] filename ...\n";
exit EX_FAILURE;
}

my %opt;
getopts('a', \%opt) or usage();
@ARGV or usage();

my @PATH = ();
my $PATHVAR = 'PATH';
my $path_sep = ':';
Expand Down

0 comments on commit 235b6a0

Please sign in to comment.