Replace multiple if statements with a switch case

This commit is contained in:
rickyjon
2019-11-12 09:34:19 +11:00
parent e9999ec202
commit ede8511a22
4 changed files with 154 additions and 175 deletions

View File

@@ -1,30 +1,35 @@
#!/bin/bash
# ____ _____
# ____ _____
# | _ \_ _| Derek Taylor (DistroTube)
# | | | || | http://www.youtube.com/c/DistroTube
# | |_| || | http://www.gitlab.com/dwt1/
# |____/ |_|
# | |_| || | http://www.gitlab.com/dwt1/
# |____/ |_|
#
# Dmenu script for launching trading programs.
declare -a options=(" tastyworks
tastytrade
thinkorswim
quit ")
declare -a options=("tastyworks
tastytrade
thinkorswim
quit")
choice=$(echo -e "${options[@]}" | dmenu -l -i -p 'System monitors: ')
if [ "$choice" == ' quit ' ]; then
echo "Program terminated."
fi
if [ "$choice" == ' tastyworks ' ]; then
case $choice in
quit)
echo "Program terminated." && exit 1
;;
tastyworks)
exec /opt/tastyworks/tastyworks
fi
if [ "$choice" == ' tastytrade ' ]; then
;;
tastytrade)
exec firefox tastytrade.com
fi
if [ "$choice" == ' thinkorswim ' ]; then
exec /home/dt/thinkorswim/thinkorswim
fi
;;
thinkorswim)
exec "$HOME/thinkorswim/thinkorswim"
;;
*)
exit 1
;;
esac