]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslogins: add --noheadings
authorKarel Zak <kzak@redhat.com>
Wed, 16 Jul 2014 09:19:09 +0000 (11:19 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Jul 2014 09:19:20 +0000 (11:19 +0200)
That's fatal mistake that this option which is required for script
is missing.

Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/lslogins.1
login-utils/lslogins.c

index 15520205480c5df83d329b869f2f38913a22923b..0a9e70357d487bddf39a680a52ed04e43590432d 100644 (file)
@@ -54,6 +54,9 @@ Show supplementary groups.
 \fB\-n\fR, \fB\-\-newline\fR
 Display each piece of information on a separate line.
 .TP
+\fB\-\-noheadings\fR
+Do not print a header line.
+.TP
 \fB\-\-notruncate\fR
 Don't truncate output.
 .TP
index 7651f091e0b60988d6acebd756f217f7e77d2ef6..96f0c70c2f07a97c3b31ee5a18fc2fc3274ed27c 100644 (file)
@@ -265,7 +265,8 @@ struct lslogins_control {
 
        const char *journal_path;
 
-       unsigned int selinux_enabled : 1;
+       unsigned int selinux_enabled : 1,
+                    noheadings : 1;
 };
 
 /* these have to remain global since there's no other reasonable way to pass
@@ -856,12 +857,15 @@ static int create_usertree(struct lslogins_control *ctl)
        return 0;
 }
 
-static struct libscols_table *setup_table(void)
+static struct libscols_table *setup_table(struct lslogins_control *ctl)
 {
        struct libscols_table *tb = scols_new_table();
        int n = 0;
+
        if (!tb)
-               return NULL;
+               errx(EXIT_FAILURE, _("failed to initialize output table"));
+       if (ctl->noheadings)
+               scols_table_enable_noheadings(tb, 1);
 
        switch(outmode) {
        case OUT_COLON:
@@ -1094,7 +1098,7 @@ static int print_pretty(struct libscols_table *tb)
 
 static int print_user_table(struct lslogins_control *ctl)
 {
-       tb = setup_table();
+       tb = setup_table(ctl);
        if (!tb)
                return -1;
 
@@ -1165,6 +1169,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
        fputs(_(" -l, --logins=<logins>    display only users from <logins>\n"), out);
        fputs(_(" -m, --supp-groups        display supplementary groups as well\n"), out);
        fputs(_(" -n, --newline            display each piece of information on a new line\n"), out);
+       fputs(_("     --noheadings         don't print headings\n"), out);
        fputs(_("     --notruncate         don't truncate output\n"), out);
        fputs(_(" -o, --output[=<list>]    define the columns to output\n"), out);
        fputs(_(" -p, --pwd                display information related to login by password.\n"), out);
@@ -1204,6 +1209,7 @@ int main(int argc, char *argv[])
                OPT_WTMP,
                OPT_BTMP,
                OPT_NOTRUNC,
+               OPT_NOHEAD,
                OPT_TIME_FMT,
        };
 
@@ -1218,6 +1224,7 @@ int main(int argc, char *argv[])
                { "supp-groups",    no_argument,        0, 'G' },
                { "newline",        no_argument,        0, 'n' },
                { "notruncate",     no_argument,        0, OPT_NOTRUNC },
+               { "noheadings",     no_argument,        0, OPT_NOHEAD },
                { "output",         required_argument,  0, 'o' },
                { "last",           no_argument,        0, 'L', },
                { "raw",            no_argument,        0, 'r' },
@@ -1347,6 +1354,9 @@ int main(int argc, char *argv[])
                case OPT_NOTRUNC:
                        coldescs[COL_GECOS].flag = 0;
                        break;
+               case OPT_NOHEAD:
+                       ctl->noheadings = 1;
+                       break;
                case OPT_TIME_FMT:
                        {
                                size_t i;