You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Use set -o errexit (a.k.a. set -e) to make your script exit when a command fails.
Then add || true to commands that you allow to fail.
2. Use set -o nounset (a.k.a. set -u) to exit when your script tries to use undeclared variables.
3. Use set -o xtrace (a.k.a set -x) to trace what gets executed. Useful for debugging.
4. Surround your variables with {}. Otherwise bash will try to access the $ENVIRONMENT_app variable in /srv/$ENVIRONMENT_app, whereas you probably intended /srv/${ENVIRONMENT}_app.
5. You don't need two equal signs when checking if [ "${NAME}" = "Kevin" ].
6. Surround your variable with " in if [ "${NAME}" = "Kevin" ], because if $NAME isn't declared, bash will throw a syntax error (also see nounset).
7. Set magic variables for current file, basename, and directory at the top of your script for convenience.