Skip to content

Instantly share code, notes, and snippets.

@facelordgists
Created January 29, 2015 00:02
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 facelordgists/94d081251dd94e1db075 to your computer and use it in GitHub Desktop.
Save facelordgists/94d081251dd94e1db075 to your computer and use it in GitHub Desktop.
How to process dash arguments
while getopts ":a:" opt; do
case $opt in
a)
echo "-a was triggered, Parameter: $OPTARG" >&2
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment