1
0
mirror of https://git.savannah.gnu.org/git/coreutils.git synced 2026-11-05 08:03:59 +03:00

(main): Fail if -l is specified with no username.

This commit is contained in:
Jim Meyering
2001-08-24 08:40:29 +00:00
parent 5f6b9742d1
commit 815dafff5a

View File

@@ -469,7 +469,7 @@ usage (int status)
printf (_("Usage: %s [OPTION]... [USER]...\n"), program_name);
printf (_("\
\n\
-l do long format output (you must specify at least one USER)\n\
-l produce long format output for the specified USERs\n\
-b omit the user's home directory and shell in long format\n\
-h omit the user's project file in long format\n\
-p omit the user's plan file in long format\n\
@@ -494,6 +494,7 @@ int
main (int argc, char **argv)
{
int optc, longind;
int n_users;
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -562,6 +563,15 @@ main (int argc, char **argv)
}
}
n_users = argc - optind;
if (do_short_format == 0 && n_users == 0)
{
error (0, 0, _("no username specified; at least one must be\
specified when using -l"));
usage (1);
}
if (do_short_format)
short_pinky (UTMP_FILE, argc - optind, argv + optind);
else