Apparently using `$(...)` inside a heredoc loses `set -e`; another spectacularly evil shell script trap. Noticed in #1954 We do want to fail if any of these commands fail, rather than emitting invalid JSON.