I just opened jq and really loved it. One thing I find myself doing a lot, but kind of like:
result=$(jq --raw-output '.some | .filters // ""')
if [[ $result ]]; then
foo
else
bar
fi
By default, an empty string seems to play more nicely with bash "truth" than, for example. if [[ $result != "null" ]], and raw output is usually needed to store only the resulting string in a variable. My question is that I use these two settings so sequentially in the scripts, maybe the best way to achieve the same functionality? Or would it be prudent (as a possible jq boost) to be able to set up a couple of env vars to control this behavior throughout the script time?
source
share