From dd3fa5f3442c30396c86c7c8097c2a1a6709b8d4 Mon Sep 17 00:00:00 2001 From: strNophix Date: Sun, 13 Feb 2022 22:44:00 +0100 Subject: [PATCH] Updated hosto option parsing --- scripts/bin/hosto | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/bin/hosto b/scripts/bin/hosto index 8b144dd..c86affa 100755 --- a/scripts/bin/hosto +++ b/scripts/bin/hosto @@ -16,8 +16,6 @@ if [[ $# -eq 0 ]]; then exit 1 fi - -POSITIONAL_ARGS=() INVENTORY_FILE="$(pwd)/inventory" while [[ $# -gt 0 ]]; do @@ -35,18 +33,22 @@ while [[ $# -gt 0 ]]; do echo $VERSION exit 1 ;; + -*|--*) + echo "hosto: unrecognized option '$1'" + help + exit 1 + ;; *) - POSITIONAL_ARGS+=("$1") - shift + break ;; esac done if [ -f $INVENTORY_FILE ]; then sudo inv-alias add $INVENTORY_FILE - eval "${POSITIONAL_ARGS[@]}" + eval $@ sudo inv-alias rm $INVENTORY_FILE else echo "hosto: Could not find inventory file at $INVENTORY_FILE" - eval "${POSITIONAL_ARGS[@]}" + eval $@ fi