Skip to content

Instantly share code, notes, and snippets.

@nyxcharon
Created June 25, 2013 17:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nyxcharon/5860750 to your computer and use it in GitHub Desktop.
Save nyxcharon/5860750 to your computer and use it in GitHub Desktop.
Using shift in bash
while [ "$1" != "" ]; do
if [ "$1" == "--hostname" ]; then
HOSTNAME=${2}; shift
echo "Hostname Defined: ${HOSTNAME}"
elif [ "$1" == "--base-image" ]; then
BASEIMAGE=${2}; shift
echo "Base-image defined: ${BASEIMAGE}"
elif [ "$1" == "--test" ]; then
TEST=true; shift
elif [ "$1" == "--help" ]; then
usage
exit 0
else
echo "Unknown Option ${1}!"
usage
exit 1;
fi
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment