]> granicus.if.org Git - jq/commitdiff
Fix error message for @tsv
authorNicolas Williams <nico@cryptonector.com>
Thu, 21 May 2015 23:20:05 +0000 (18:20 -0500)
committerNicolas Williams <nico@cryptonector.com>
Thu, 21 May 2015 23:20:15 +0000 (18:20 -0500)
builtin.c

index 4747f618fc515ddfe0e3a00454e0c600f6ed0550..8ea8319c72876df0bf2abe4bae7fd40ecfdf9c6a 100644 (file)
--- a/builtin.c
+++ b/builtin.c
@@ -375,11 +375,14 @@ static jv f_format(jq_state *jq, jv input, jv fmt) {
     return f_tostring(jq, input);
   } else if (!strcmp(fmt_s, "csv") || !strcmp(fmt_s, "tsv")) {
     const char *quotes, *sep, *escapings;
+    const char *msg;
     if (!strcmp(fmt_s, "csv")) {
+      msg = "cannot be csv-formatted, only array";
       quotes = "\"";
       sep = ",";
       escapings = "\"\"\"\0";
     } else {
+      msg = "cannot be tsv-formatted, only array";
       assert(!strcmp(fmt_s, "tsv"));
       quotes = "";
       sep = "\t";
@@ -387,7 +390,7 @@ static jv f_format(jq_state *jq, jv input, jv fmt) {
     }
     jv_free(fmt);
     if (jv_get_kind(input) != JV_KIND_ARRAY)
-      return type_error(input, "cannot be csv-formatted, only array");
+      return type_error(input, msg);
     jv line = jv_string("");
     jv_array_foreach(input, i, x) {
       if (i) line = jv_string_append_str(line, sep);