Debugging and Error Handling
Enabling Debugging
- Use
-x
to enable debugging.
#!/bin/bash
set -x
echo "Debugging Enabled"
set +x
echo "Debugging Disabled"
Handling Errors
#!/bin/bash
if ! mkdir /some/nonexistent/directory; then
echo "Failed to create directory"
fi