Skip to content

Instantly share code, notes, and snippets.

@siroken3
Created March 18, 2014 05:12
Show Gist options
  • Select an option

  • Save siroken3/9613918 to your computer and use it in GitHub Desktop.

Select an option

Save siroken3/9613918 to your computer and use it in GitHub Desktop.
bashでgetopts 使うテンプレ
aaa=""
bbb=""
function errorexit()
{
echo $1
exit
}
function usage()
{
errorexit "${0} -a aaa -b bbb"
}
while getopts :a:b OPT
do
case $OPT in
a) aaa=$OPTARG
;;
b) bbb=$OPTARG
;;
*) usage
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment