who: add -a (by Tito)
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>
Fri, 16 Nov 2007 05:24:43 +0000 (05:24 +0000)
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>
Fri, 16 Nov 2007 05:24:43 +0000 (05:24 +0000)
git-svn-id: svn://busybox.net/trunk/busybox@20430 69ca8d6d-28ef-0310-b511-8ec308f3f277

coreutils/who.c
include/usage.h

index 7259744..f336c95 100644 (file)
@@ -46,15 +46,15 @@ int who_main(int argc, char **argv)
        struct utmp *ut;
        struct stat st;
        char *name;
+       unsigned opt;
 
-       if (argc > 1) {
-               bb_show_usage();
-       }
+       opt_complementary = "=0";
+       opt = getopt32(argv, "a");
 
        setutent();
        printf("USER       TTY      IDLE      TIME            HOST\n");
        while ((ut = getutent()) != NULL) {
-               if (ut->ut_user[0] && ut->ut_type == USER_PROCESS) {
+               if (ut->ut_user[0] && (opt || ut->ut_type == USER_PROCESS)) {
                        /* ut->ut_line is device name of tty - "/dev/" */
                        name = concat_path_file("/dev", ut->ut_line);
                        str6[0] = '?';
index 953645b..592316a 100644 (file)
@@ -4112,9 +4112,11 @@ USE_FEATURE_RUN_PARTS_FANCY("\n  -l      Prints names of all matching files even when
        "/bin/login\n"
 
 #define who_trivial_usage \
-       " "
+       "[-a]"
 #define who_full_usage \
-       "Print the current user names and related information"
+       "Show who is logged on" \
+       "\n\nOptions:\n" \
+       "       -a      show all"
 
 #define whoami_trivial_usage \
        ""