From 3e9614542c32eb29f278ab1913daabe95b6a7b30 Mon Sep 17 00:00:00 2001 From: Bo-Chun Louis Chen <louistw@uab.edu> Date: Thu, 5 Sep 2024 19:09:43 -0500 Subject: [PATCH] refactor: use variable for group options --- user_migrate.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/user_migrate.sh b/user_migrate.sh index 25b1279..1edd5d9 100644 --- a/user_migrate.sh +++ b/user_migrate.sh @@ -1,13 +1,16 @@ #!/bin/bash +group_options=(gpfs4 gpfs5) + user=$1 group_to=$2 if [[ -z "${group_to}" ]]; then echo "Usage: $0 USER TARGET_GROUP" exit 1 -elif [[ "${group_to}" != "gpfs4" && "${group_to}" != "gpfs5" ]]; then - echo "Target group should be \"gpfs4\" or \"gpfs5\", got \"${group_to}\"." +elif [[ ! " ${group_options[*]} " =~ [[:space:]]${group_to}[[:space:]] ]]; then + echo "Invalid target group" + echo "Available options: ${group_options[*]}, got ${group_to}" exit 1 fi @@ -21,7 +24,6 @@ fi cd /cm/shared/rabbitmq_agents || exit source venv/bin/activate - if [[ "$group_to" == "gpfs4" ]]; then group_from=gpfs5 else -- GitLab