From 56dde005d3ec10969b8433fdc6eedb6f6b6d61e6 Mon Sep 17 00:00:00 2001 From: Ankeet Presswala Date: Mon, 29 Jun 2020 22:10:33 +0000 Subject: [PATCH] Fixed getopt bug --- draft-rm-install | 5 +++-- draft-rm-uninstall | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/draft-rm-install b/draft-rm-install index a5b4bcd..bdab24c 100755 --- a/draft-rm-install +++ b/draft-rm-install @@ -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 @@ -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 diff --git a/draft-rm-uninstall b/draft-rm-uninstall index da31a7d..0a7a7a6 100755 --- a/draft-rm-uninstall +++ b/draft-rm-uninstall @@ -17,6 +17,7 @@ while getopts ":y" option; do case $option in y) answer="Y" + shift ;; *) usage @@ -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