use exitcode 3 for usage errors - json2tsv - JSON to TSV converter (HTM) git clone git://git.codemadness.org/json2tsv (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit 65ee8e6903bc3c072a2e55fdd2501b0296fbdf59 (DIR) parent 7c6507b10767029b3d4585e3e65d231f66fa904b (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org> Date: Sat, 25 Sep 2021 11:36:12 +0200 use exitcode 3 for usage errors Diffstat: M json2tsv.1 | 4 ++-- M json2tsv.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) --- (DIR) diff --git a/json2tsv.1 b/json2tsv.1 @@ -95,8 +95,8 @@ s for string .El .Sh EXIT STATUS .Nm -exits with the exit status 0 on success, 1 on a parse error or 2 when -out of memory. +exits with the exit status 0 on success, 1 on a parse error, 2 when out of +memory or 3 with an usage error. .Sh EXAMPLES .Bd -literal json2tsv < input.json | awk -F '\\t' '$1 == ".url" { print $3 }' (DIR) diff --git a/json2tsv.c b/json2tsv.c @@ -113,7 +113,7 @@ readnum(const char *s, int base) l = strtol(s, &end, base); if (errno || s == end || *end != '\0' || l < 0 || l > 255) { fprintf(stderr, "invalid number\n"); - exit(1); + exit(3); } return (int)l; @@ -124,7 +124,7 @@ readchar(const char *s) { if (!*s) { fprintf(stderr, "invalid character\n"); - exit(1); + exit(3); } else if (strlen(s) == 1) { return *s; } else if (*s == '\\') { @@ -137,7 +137,7 @@ readchar(const char *s) case 'x': return readnum(++s, 16); /* hexadecimal */ default: fprintf(stderr, "unsupported escape character\n"); - exit(1); + exit(3); } } /* base 0 (decimal, octal, hex) using strtol() format */ @@ -148,7 +148,7 @@ void usage(const char *argv0) { fprintf(stderr, "usage: %s [-n] [-r] [-F fs] [-R rs]\n", argv0); - exit(1); + exit(3); } int