aboutsummaryrefslogtreecommitdiffstats
path: root/sys-utils
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2025-09-03 10:12:31 +0200
committerKarel Zak <kzak@redhat.com>2025-09-03 10:12:31 +0200
commit0c57a76da61e5ab1f15eada0553b2ef85026269c (patch)
treed183481a53b99b0625c52962386a0cb44a2df7a5 /sys-utils
parent129c99c0e1cce307e64a1ee6685d59b1f3e016de (diff)
parentfd6d6676c018ff7076fbb0193c87dd445a92c3d2 (diff)
downloadutil-linux-0c57a76da61e5ab1f15eada0553b2ef85026269c.tar.gz
Merge branch 'fix/fix_lsns_list_columns_opt' of https://github.com/cgoesche/util-linux-fork
* 'fix/fix_lsns_list_columns_opt' of https://github.com/cgoesche/util-linux-fork: bash-completion: (lsns) add -H/--list-columns options lsns: fix --list-columns option Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils')
-rw-r--r--sys-utils/lsns.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c
index 8133c11318..074df806bf 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_columns(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_columns(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;