diff options
-rwxr-xr-x | lxc-attach | 24 | ||||
-rwxr-xr-x | lxc-create | 24 | ||||
-rwxr-xr-x | lxc-destroy | 24 | ||||
-rwxr-xr-x | lxc-info | 34 |
4 files changed, 38 insertions, 68 deletions
@@ -13,22 +13,14 @@ CMD=$(awk -F'-- ' '{print $2}' <<< "$@") -POSITIONAL=() -while [[ $# -gt 0 ]] -do -key="$1" - -case $key in - -n) - LXC_NAME="$2" - shift - shift - ;; - *) - POSITIONAL+=("$1") - shift - ;; -esac +while getopts "n:" opt; do + case $opt in + n) + LXC_NAME="$OPTARG" + ;; + *) + ;; + esac done if [ "$CMD" ]; then @@ -14,22 +14,14 @@ # Get the list of requested packages. PACKAGES=$(sed 's/,/ /g' <<< $(cut -d' ' -f1 <<< $(awk -F'--packages ' '{print $2}' <<< "$@"))) -POSITIONAL=() -while [[ $# -gt 0 ]] -do -key="$1" - -case $key in - -n) - LXC_NAME="$2" - shift - shift - ;; - *) - POSITIONAL+=("$1") - shift - ;; -esac +while getopts "qt:n:" opt; do + case $opt in + n) + LXC_NAME="$OPTARG" + ;; + *) + ;; + esac done if [ "$PACKAGES" ]; then diff --git a/lxc-destroy b/lxc-destroy index bc020c1..92aac7e 100755 --- a/lxc-destroy +++ b/lxc-destroy @@ -11,22 +11,14 @@ # # Mocks lxc-destroy command which is used by LAVA. -POSITIONAL=() -while [[ $# -gt 0 ]] -do -key="$1" - -case $key in - -n) - LXC_NAME="$2" - shift - shift - ;; - *) - POSITIONAL+=("$1") - shift - ;; -esac +while getopts "fn:" opt; do + case $opt in + n) + LXC_NAME="$OPTARG" + ;; + *) + ;; + esac done if [ "$LXC_NAME" ]; then @@ -11,26 +11,20 @@ # # Mocks lxc-info command which is used by LAVA. -while [[ $# -gt 0 ]] -do -key="$1" - -case $key in - -sH) - STATUS=1 - shift - ;; - -iH) - IP=1 - shift - ;; - -n) - LXC_NAME="$2" - shift - shift - ;; - *) -esac +while getopts "s:i:n:" opt; do + case $opt in + n) + LXC_NAME="$OPTARG" + ;; + s) + STATUS=1 + ;; + i) + IP=1 + ;; + *) + ;; + esac done if [ "$STATUS" ]; then |