Skip to content

Instantly share code, notes, and snippets.

@tkfm-yamaguchi
Last active August 29, 2015 14:05
Show Gist options
  • Save tkfm-yamaguchi/5c94d4f3a96813271565 to your computer and use it in GitHub Desktop.
Save tkfm-yamaguchi/5c94d4f3a96813271565 to your computer and use it in GitHub Desktop.
getopts is a command of sh/bash
#!/bin/bash -x
while getopts d opt; do
case $opt in
d) DEBUG="y" ;;
esac
done
if [ -z $DEBUG ]; then
echo "NO DEBUG"
else
echo "DEBUG"
fi
# it could get another arguments
shift $((OPTIND - 1))
echo ${1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment