I'm using the -e flag.
Usage:
#!/bin/bash -e
Explained:
-e Exit immediately if a simple command (see SHELL GRAMMAR above) exits with a non-zero status
When a command in the script fails, the script exits and doesn't continue to execute the rest of the commands, which is exactly what I want.
But, the failure contains just the info that the failed command chooses to disclose.
Sometimes the failed command is very complicated, like a curl with many headers.
How do I print the failed command? I mean, immediately after it failed.
I know I can use the -x bash flag but it will print all of the executed commands. I'd like to see just the failed one.