From 815dafff5a635c3417fe1ef32437527c44bc71db Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 24 Aug 2001 08:40:29 +0000 Subject: (main): Fail if -l is specified with no username. --- src/pinky.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pinky.c b/src/pinky.c index 15d4fde2a..53bc33ef5 100644 --- a/src/pinky.c +++ b/src/pinky.c @@ -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 -- cgit v1.2.3-70-g09d2