---------------------------------------------------
| Date: 2001-11-25 03:49:52 |
| Filename: switch.sh |
| Author: mind@metalshell.com |
| |
| http://www.metalshell.com/ |
---------------------------------------------------
# Switch example by mindsport
# Contact: mind@infract.net
#
# $0 = program name: ./switch.sh
# $1 = first switch after ./switch.sh
# $2 = second switch after ./switch.sh
# etc..
if [ -z $1 ]; then # Nothing was put after ./switch.sh
echo "Usage: $0 <-switch>"
echo
echo "Switches:"
echo " -a "
echo " -b "
exit # ends script at this point
fi
if [ $1 = "-a" ]; then
echo "You picked switch -a"
# You can also add 'exit' here to finish the script without going on..
fi
if [ $1 = "-b" ]; then
echo "You picked switch -b"
# also you can add 'exit' here to finish the script
fi
# This is an example of a second switch like ./switch -a -b
if [ -z $2 ]; then # nothing was entered for switch2 so we ..
exit # exit....
else
if [ $2 = "-a" ]; then
echo "You picked switch -a"
# Could finish the script with 'exit'
fi
if [ $2 = "-b" ]; then
echo "You picked switch -b"
# Also could finish with 'exit'
fi
fi