Skip to content

Commit

Permalink
Remove getopts from scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
lkrcal committed Jun 4, 2019
1 parent 467ccc5 commit 3e1600d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
18 changes: 1 addition & 17 deletions start.sh
Expand Up @@ -65,34 +65,18 @@ startEnvironment() {
echoInfo "It may take a while before ioFog stack creates all ${ENVIRONMENT} microservices."
}

! getopt -T
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
echoError 'Your getopt version is insufficient!'
exit 2
fi

! OPTIONS=$(getopt --options="h" --longoptions="help" --name "$0" -- $@)
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
printHelp
exit 1
fi
eval set -- "${OPTIONS}"

ENVIRONMENT=''
while [[ "$#" -ge 1 ]]; do
case "$1" in
-h|--help)
printHelp
exit 0
;;
--)
shift
;;
*)
if [[ -n "${ENVIRONMENT}" ]]; then
echoError "Cannot specify more than one environment!"
printHelp
exit1
exit 1
fi
ENVIRONMENT=$1
shift
Expand Down
21 changes: 4 additions & 17 deletions stop.sh
Expand Up @@ -14,30 +14,17 @@ printHelp() {
echo " -h, --help print this help / usage"
}

! getopt -T
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
echoError 'Your getopt version is insufficient!'
exit 2
fi

! OPTIONS=$(getopt --options="h" --longoptions="help" --name "$0" -- $@)
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
printHelp
exit 1
fi
eval set -- "$OPTIONS"

while [[ "$#" -ge 1 ]]; do
case "$1" in
-h|--help)
printHelp
exit 0
;;
--)
shift
;;
*)
echoError "Unrecognized argument!"
echoError "Unrecognized argument: \"$1\""
printHelp
exit 1
;;
esac
done

Expand Down

0 comments on commit 3e1600d

Please sign in to comment.