Given this script:
#!/bin/bash
COMMAND=$(echo test | jq)
if [[ $COMMAND == *"error"* ]]; then
echo failed
else
echo success
fi
Since the output of $(COMMAND) is the following: parse error: Invalid literal at line 2, column 0, I'd expect to have as output of that script failed, but I'm having success.
How can I parse the error that I got on scripts?