Skip to content

Commit

Permalink
uname: reject command arguments (#478)
Browse files Browse the repository at this point in the history
* As with bin/arch, uname does not accept any arguments
* For this case the Linux version fails with 'extra operand' error and the OpenBSD version prints usage
* POD after __END__
  • Loading branch information
mknos committed Mar 2, 2024
1 parent d783ed2 commit cd4d45f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bin/uname
Expand Up @@ -17,8 +17,10 @@ use strict;
use Getopt::Std;
use vars qw($opt_s $opt_n $opt_r $opt_v $opt_m $opt_a);

my $usage = "usage: uname [-snrvma]\n";
getopts "snrvma" or die $usage;
sub usage { die "usage: uname [-snrvma]\n" }

getopts('snrvma') or usage();
usage() if @ARGV;

my ($sysname, $nodename, $release, $version, $machine ) = uname;
my @out = ();
Expand All @@ -43,6 +45,7 @@ push @out, $sysname unless @out;

print "@out\n";

__END__
=head1 NAME
Expand Down

0 comments on commit cd4d45f

Please sign in to comment.