Skip to content

Commit

Permalink
Fixed getopt bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sudocurse committed Jun 29, 2020
1 parent 9379c9d commit 56dde00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions draft-rm-install
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ usage() {
echo "Type '$0 --help' or '$0 -h' to see this message."
}

while getopts ":y" option; do
while getopts ":y:" option; do
case $option in
y)
answer="Y"
shift
;;
*)
usage
Expand All @@ -28,7 +29,7 @@ while getopts ":y" option; do
esac
done

if [ $OPTIND != 1 ]; then
if [ $OPTIND < 1 || $OPTIND > 2 ]; then
usage
exit 1
fi
Expand Down
3 changes: 2 additions & 1 deletion draft-rm-uninstall
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ while getopts ":y" option; do
case $option in
y)
answer="Y"
shift
;;
*)
usage
Expand All @@ -25,7 +26,7 @@ while getopts ":y" option; do
esac
done

if [ $OPTIND != 1 ]; then
if [ $OPTIND < 1 || $OPTIND > 2 ]; then
usage
exit 1
fi
Expand Down

0 comments on commit 56dde00

Please sign in to comment.