From: Karel Zak Date: Fri, 6 Mar 2020 15:34:51 +0000 (+0100) Subject: lsirq: add -P option X-Git-Tag: v2.36-rc1~196^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a20c0dec3ce4c15f95863ce3529621c9394c1d3;p=thirdparty%2Futil-linux.git lsirq: add -P option Signed-off-by: Karel Zak --- diff --git a/sys-utils/irq-common.c b/sys-utils/irq-common.c index f3dc49b439..2992d3c7da 100644 --- a/sys-utils/irq-common.c +++ b/sys-utils/irq-common.c @@ -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")); diff --git a/sys-utils/irq-common.h b/sys-utils/irq-common.h index f5884b7114..9515daf49a 100644 --- a/sys-utils/irq-common.h +++ b/sys-utils/irq-common.h @@ -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); diff --git a/sys-utils/lsirq.1 b/sys-utils/lsirq.1 index 7e9117d327..ed48c541e4 100644 --- a/sys-utils/lsirq.1 +++ b/sys-utils/lsirq.1 @@ -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). +.TP .BR \-V ", " \-\-version Display version information and exit. .TP diff --git a/sys-utils/lsirq.c b/sys-utils/lsirq.c index 35e726cd17..3d7e26abb5 100644 --- a/sys-utils/lsirq.c +++ b/sys-utils/lsirq.c @@ -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 define which output columns to use\n"), stdout); fputs(_(" -s, --sort 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;