]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsirq: add -P option
authorKarel Zak <kzak@redhat.com>
Fri, 6 Mar 2020 15:34:51 +0000 (16:34 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 6 Mar 2020 15:34:51 +0000 (16:34 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/irq-common.c
sys-utils/irq-common.h
sys-utils/lsirq.1
sys-utils/lsirq.c

index f3dc49b4396cdf34532f546c80401fc369cbfd27..2992d3c7da334716847d73abd08198762ecd97ca 100644 (file)
@@ -108,6 +108,7 @@ static struct libscols_table *new_scols_table(struct irq_output *out)
        }
        scols_table_enable_json(table, out->json);
        scols_table_enable_noheadings(table, out->no_headings);
+       scols_table_enable_export(table, out->pairs);
 
        if (out->json)
                scols_table_set_name(table, _("interrupts"));
index f5884b711442c7cf2dab448daa78be812cd9472b..9515daf49aad9d74ab47ccf0fe9e816571e75291 100644 (file)
@@ -41,8 +41,9 @@ struct irq_output {
        irq_cmp_t *sort_cmp_func;
 
        unsigned int
-               json:1,
-               no_headings:1;
+               json:1,         /* JSON output */
+               pairs:1,        /* export, NAME="value" aoutput */
+               no_headings:1;  /* don't print header */
 };
 
 int irq_column_name_to_id(char const *const name, size_t const namesz);
index 7e9117d3278423c1cd25ede07603d5361658e1c8..ed48c541e41d85c7434e75dd08335ca59d4c23eb 100644 (file)
@@ -26,6 +26,10 @@ names.
 .BR \-J , " \-\-json
 Use JSON output format.
 .TP
+.BR \-P , " \-\-pairs
+Produce output in the form of key="value" pairs.  All potentially unsafe characters
+are hex-escaped (\\x<code>).
+.TP
 .BR \-V ", " \-\-version
 Display version information and exit.
 .TP
index 35e726cd1785d7d90e984258b693a94d91575090..3d7e26abb590c7ed18a2c0e85a49eda9f8c0a908 100644 (file)
@@ -60,6 +60,7 @@ static void __attribute__((__noreturn__)) usage(void)
 
        fputs(USAGE_OPTIONS, stdout);
        fputs(_(" -J, --json           use JSON output format\n"), stdout);
+       fputs(_(" -P, --pairs          use key=\"value\" output format\n"), stdout);
        fputs(_(" -n, --noheadings     don't print headings\n"), stdout);
        fputs(_(" -o, --output <list>  define which output columns to use\n"), stdout);
        fputs(_(" -s, --sort <column>  specify sort column\n"), stdout);
@@ -83,6 +84,7 @@ int main(int argc, char **argv)
                {"noheadings", no_argument, NULL, 'n'},
                {"output", required_argument, NULL, 'o'},
                {"json", no_argument, NULL, 'J'},
+               {"pairs", no_argument, NULL, 'P'},
                {"help", no_argument, NULL, 'h'},
                {"version", no_argument, NULL, 'V'},
                {NULL, 0, NULL, 0}
@@ -92,11 +94,14 @@ int main(int argc, char **argv)
 
        setlocale(LC_ALL, "");
 
-       while ((c = getopt_long(argc, argv, "no:s:hJV", longopts, NULL)) != -1) {
+       while ((c = getopt_long(argc, argv, "no:s:hJPV", longopts, NULL)) != -1) {
                switch (c) {
                case 'J':
                        out.json = 1;
                        break;
+               case 'P':
+                       out.pairs = 1;
+                       break;
                case 'n':
                        out.no_headings = 1;
                        break;