From 1fa9e3f9084123497b3be9d9505c2d9cb6688762 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 16:48:27 -0600 Subject: [PATCH] regex changes for ignore --- functions/menu.sh | 2 +- heavy_script.sh | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 2d4195a0..95008b4a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -142,7 +142,7 @@ case $selection in ;; 2 | -i) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - ! [[ $up_ignore =~ ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is invalid, that is not the name youre using for your application" && sleep 5 && continue + ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is invalid, that is not the name youre using for your application" && sleep 5 && continue update_selection+=("-i" "$up_ignore") ;; 3 | -r) diff --git a/heavy_script.sh b/heavy_script.sh index 5d539c1d..61caec9a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -71,15 +71,11 @@ do rollback="true" ;; i) - # Check next positional parameter - eval nextopt=${!OPTIND} - # existing or starting with dash? - if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND + 1)) - ignore+=("$nextopt") - else - echo "Option: \"-i\" requires an argument" + if ! [[ $OPTARG =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]]; then # Using case insensitive version of the regex used by Truenas Scale + echo -e "Error: \"$OPTARG\" is invalid, that is not the name youre using for your application" exit + else + ignore+=("$OPTARG") fi ;; t)