From 4ba3ce17bc9d343df9a118d3da0f139570567e28 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 8 Mar 2023 18:28:30 +0100 Subject: [PATCH] Refactor skip_action micro optimization. No forks used readability improved by avoiding regex. --- lib/tiny-cloud/init-common | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/tiny-cloud/init-common b/lib/tiny-cloud/init-common index ef6bbb2..8944f0f 100644 --- a/lib/tiny-cloud/init-common +++ b/lib/tiny-cloud/init-common @@ -19,11 +19,11 @@ bootstrap_incomplete() { rm -f "$TINY_CLOUD_VAR"/.bootstrap-complete ; } # should we skip this action? skip_action() { local action="$1" - - # no action? don't skip. - [ -z "$action" ] && return 1 - - # action not in the skip list? - echo "$SKIP_INIT_ACTIONS" | grep -Eq "\b$action\b" || return 1 - printf " SKIPPING" + for i in $SKIP_INIT_ACTIONS; do + if [ "$i" = "$action" ]; then + printf " SKIPPING" + return 0 + fi + done + return 1 }