Skip to content

Instantly share code, notes, and snippets.

@jasdeepkhalsa
Last active April 9, 2020 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasdeepkhalsa/8b6f8179e64e002fddcef750a03dd2e6 to your computer and use it in GitHub Desktop.
Save jasdeepkhalsa/8b6f8179e64e002fddcef750a03dd2e6 to your computer and use it in GitHub Desktop.
Automatically determining values in a Bash script
#!/usr/bin/env bash
APP=a
if [[ "$1" ]]; then
APP="$1"
fi
# This is automatically determined by the $APP variable
CONFIG="app-default.config"
case "$APP" in
a)
CONFIG="app-a.config"
;;
b)
CONFIG="app-b.config"
;;
*)
CONFIG="app-default.config"
;;
esac
echo -e "The app is $APP\nLoaded with config file $CONFIG"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment