From ded16baac6974ff1035bf1242b59bba75cbe630f Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Thu, 7 Nov 2019 10:24:56 +0700 Subject: [PATCH] Add option parsing --- checkvolumesize | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 checkvolumesize diff --git a/checkvolumesize b/checkvolumesize new file mode 100755 index 0000000..66b31e9 --- /dev/null +++ b/checkvolumesize @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +POSITIONAL=() +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + --token) + TOKEN="$2" + shift # past argument + shift # past value + ;; + --device) + DEVICE="$2" + shift # past argument + shift # past value + ;; + --volume-name) + VOLUME_NAME="$2" + shift # past argument + shift # past value + ;; + --volume-region) + VOLUME_REGION="$2" + shift # past argument + shift # past value + ;; + --buffer) + BUFFER="$2" + shift # past argument + shift # past value + ;; + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; +esac +done +set -- "${POSITIONAL[@]}" # restore positional parameters + +echo "TOKEN = ${TOKEN}" +echo "DEVICE = ${DEVICE}" +echo "VOLUME_NAME = ${VOLUME_NAME}" +echo "VOLUME_REGION = ${VOLUME_REGION}" +echo "BUFFER = ${BUFFER}"