Browse files

Update getopts.sh

  • Loading branch information...
1 parent 9981531 commit f1af38dce95d13e6981a97ccbd78cf975c06f426 @soarpenguin committed Dec 13, 2013
Showing with 16 additions and 0 deletions.
  1. +16 −0 bashrc/getopts.sh
View
16 bashrc/getopts.sh
@@ -16,4 +16,20 @@ while getopts "cn" opt; do
esac
done
+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
+
echo "The type is $Type";

0 comments on commit f1af38d

Please sign in to comment.