Introduction
Introduction Statistics Contact Development Disclaimer Help
jaq: small tweaks and code-style - json2tsv - JSON to TSV converter
git clone git://git.codemadness.org/json2tsv
Log
Files
Refs
README
LICENSE
---
commit 7c73ed4db155770fb3c42edd396b894b209bdf41
parent 6c4f4766a6151180fafe4f5d8d7e396e2a0d1876
Author: Hiltjo Posthuma <[email protected]>
Date: Thu, 1 Sep 2022 01:39:35 +0200
jaq: small tweaks and code-style
Diffstat:
M jaq | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/jaq b/jaq
@@ -1,7 +1,6 @@
#!/bin/sh
-
nflag=""
-if test "$1" = "-n"; then
+if [ "$1" = "-n" ]; then
nflag="-n"
shift
fi
@@ -12,10 +11,10 @@ if [ $# -le 0 ]; then
fi
expr="$*"
-# simulate pipefail if JSON data is invalid.
+# POSIX way to simulate -o pipefail if JSON data is invalid.
statusfile=$(mktemp)
trap -- "rm -f \"${statusfile}\"" "EXIT"
{ json2tsv ${nflag} -r -F '\x1f' -R '\x1e'; echo $? >"${statusfile}"; } | \
LC_ALL=C awk "BEGIN { FS = \"\x1f\"; RS = \"\x1e\" }${expr}"
statuscode="$(cat "${statusfile}" 2>/dev/null)$?"
-test "${statuscode}" = "00"
+[ "${statuscode}" = "00" ]
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.