Skip to content

Instantly share code, notes, and snippets.

@atton
Created April 12, 2012 07:38
Show Gist options
  • Save atton/2365464 to your computer and use it in GitHub Desktop.
Save atton/2365464 to your computer and use it in GitHub Desktop.
shell script option test
#!/bin/sh
# shell script option test
a=0
b=0
while getopts ab opt
do
case ${opt} in
a)
a=1 ;;
b)
b=1 ;;
esac
done
if [ $a -eq 1 ] ; then
shift
echo option a
fi
if [ $b -eq 1 ] ; then
shift
echo option b
fi
if [ $a -eq 0 ] ; then
if [ $b -eq 0 ] ; then
echo option none
fi
fi
echo $*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment