3 ms·
The problem with the `-e` flag is if you want to output custom errors, say json. I prefer to have bash inspect status codes. if [ $? != 0 ]; then e
by nodesocket 12y ago
The problem with the `-e` flag is if you want to output custom errors, say json. I prefer to have bash inspect status codes.
if [ $? != 0 ]; then
echo "{\"error\": \"Failed to connect to the database.\"}" >&2;
exit 1;
fi
- matt_kantor 12y agoJust do it all in the condition instead of separately: if ! command_that_may_error; then echo "{\"error\": \"Failed to connect to the database.\"}" >&2; exit 1; fi