diff options
author | Karel Zak | 2017-05-05 12:49:51 +0200 |
---|---|---|
committer | Karel Zak | 2017-05-05 12:49:51 +0200 |
commit | cb3fdf2ae9836d48b6176b4a9735d38796cbda88 (patch) | |
tree | 27ab602e153a957dc3960a7d631ccd90d1e40d09 /text-utils/column.c | |
parent | blkid: fix return code when display the version (diff) | |
download | kernel-qcow2-util-linux-cb3fdf2ae9836d48b6176b4a9735d38796cbda88.tar.gz kernel-qcow2-util-linux-cb3fdf2ae9836d48b6176b4a9735d38796cbda88.tar.xz kernel-qcow2-util-linux-cb3fdf2ae9836d48b6176b4a9735d38796cbda88.zip |
column: require column names for JSON
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils/column.c')
-rw-r--r-- | text-utils/column.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/text-utils/column.c b/text-utils/column.c index 4d859e013..cdfb23390 100644 --- a/text-utils/column.c +++ b/text-utils/column.c @@ -393,8 +393,14 @@ static int add_line_to_table(struct column_control *ctl, wchar_t *wcs) while ((wcdata = local_wcstok(wcs, ctl->input_separator, ctl->greedy, &sv))) { char *data; - if (scols_table_get_ncols(ctl->tab) < n + 1) + if (scols_table_get_ncols(ctl->tab) < n + 1) { + if (scols_table_is_json(ctl->tab)) + errx(EXIT_FAILURE, _("line %zu: for JSON the name of the " + "column %zu is required"), + scols_table_get_nlines(ctl->tab) + 1, + n + 1); scols_table_new_column(ctl->tab, NULL, 0, 0); + } if (!ln) { ln = scols_table_new_line(ctl->tab, NULL); if (!ln) |