3 ms·
Another useful flag is -x, which enables tracing (Bash will print each command before executing it). You can disable it again with set +x (same goes for +e, +u
by pzmarzly 6y ago
Another useful flag is -x, which enables tracing (Bash will print each command before executing it).
You can disable it again with set +x (same goes for +e, +u and afaik +o pipefail)
Also, please use shellcheck - https://www.shellcheck.net/ https://www.shellcheck.net/
EDIT: Also, please don't modify scripts while they are running.
- aidenn0 6y agoHere's a workaround for modifying scripts while they are running; it works because function bodies are read and parsed entirely when they are defined. main() { script goes here exit } main "$@"
- 0xmohit 6y agoSpecifying PS4 when using the -x flag can be even more helpful while debugging. The variable PS4 denotes the value is the prompt printed before the command line is echoed when the -x option is set and defaults to : followed by space. A number of useful debugging tips are listed at <https://wiki.bash-hackers.org/scripting/debuggingtips https://wiki.bash-hackers.org/scripting/debuggingtips>.