From: Christian Goeschel Ndjomouo Date: Tue, 2 Sep 2025 21:13:44 +0000 (-0400) Subject: lsns: fix --list-columns option X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6246de3e535f4d22f606f2b1b68fc991d2181ac2;p=thirdparty%2Futil-linux.git lsns: fix --list-columns option This patch makes it so that we continue parsing all CLI options even when we find -H/--list-columns. Therefore we don't miss any format specifying options, namely --json and --raw, and print the columns in the desired form. Closes: #3725 Signed-off-by: Christian Goeschel Ndjomouo --- diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c index 6b6ad8355..074df806b 100644 --- a/sys-utils/lsns.c +++ b/sys-utils/lsns.c @@ -1591,15 +1591,14 @@ static void __attribute__((__noreturn__)) usage(void) exit(EXIT_SUCCESS); } -static void __attribute__((__noreturn__)) list_colunms(bool raw, bool json) +static void __attribute__((__noreturn__)) list_colunms(struct lsns *ls) { - struct libscols_table *col_tb = xcolumn_list_table_new("lsns-columns", stdout, raw, json); + struct libscols_table *col_tb = xcolumn_list_table_new("lsns-columns", stdout, ls->raw, ls->json); for (size_t i = 0; i < ARRAY_SIZE(infos); i++) xcolumn_list_table_append_line(col_tb, infos[i].name, infos[i].json_type, NULL, _(infos[i].help)); - scols_print_table(col_tb); scols_unref_table(col_tb); @@ -1619,7 +1618,7 @@ static dev_t read_nsfs_dev(void) int main(int argc, char *argv[]) { struct lsns ls; - int c, force_list = 0; + int c, force_list = 0, collist = 0; int r = 0; char *outarg = NULL; enum { @@ -1731,8 +1730,8 @@ int main(int argc, char *argv[]) ls.filter = new_filter(optarg); break; case 'H': - list_colunms(ls.raw, ls.json); - + collist = 1; + break; case 'h': usage(); case 'V': @@ -1742,6 +1741,9 @@ int main(int argc, char *argv[]) } } + if (collist) + list_colunms(&ls); + if (!ls.fltr_ntypes) { size_t i;