Skip to content

Commit

Permalink
id: don't ignore extra arguments (#494)
Browse files Browse the repository at this point in the history
* This version of id follows BSD and only supports one user argument
* Instead of ignoring extra arguments, print usage and exit as done by OpenBSD version
* test1: valid usage: "perl id 0" --> display root user on my Linux system
* test2: invalid usage: "perl id 0 0 0 0 0" --> previously did not raise error
* test3: valid usage: "perl id" --> user taken as "current user"
  • Loading branch information
mknos committed Mar 12, 2024
1 parent f0fbf8a commit fba7f95
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions bin/id
Expand Up @@ -32,6 +32,7 @@ if ( ($opt_G + $opt_g + $opt_p + $opt_u) > 1 ) {
my($user,$pw,$uid,$gid,$tp);

if ( @ARGV ) { # user specified
help() if scalar(@ARGV) > 1;
($user,$pw,$uid,$gid) = getpwnam $ARGV[0];
if (!defined($uid) && $ARGV[0] =~ m/\A[0-9]+\Z/) {
($user,$pw,$uid,$gid) = getpwuid $ARGV[0];
Expand Down

0 comments on commit fba7f95

Please sign in to comment.