From dde2e7e56fc03561c2d73a3766406efc9bd5d2c0 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 26 Jan 2022 16:33:22 +0100 Subject: [PATCH] Update 90-config_yaml.sh --- .templates/90-config_yaml.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.templates/90-config_yaml.sh b/.templates/90-config_yaml.sh index beb62ee24..ea8d0fd6e 100644 --- a/.templates/90-config_yaml.sh +++ b/.templates/90-config_yaml.sh @@ -9,7 +9,7 @@ CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION") # Check if config file is there, or create one from template -if [ -f $CONFIGSOURCE ]; then +if [ -f "$CONFIGSOURCE" ]; then echo "Using config file found in $CONFIGSOURCE" else echo "No config file, creating one from template" @@ -25,7 +25,7 @@ else curl -L -f -s $TEMPLATESOURCE --output $CONFIGSOURCE fi # Need to restart - bashio::log.fatal "Config file not found, creating a new one. Please customize the file in $CONFIGSOURCE before restarting." + bashio::log.fatal "Config file not found, creating a new one. Please customize the file in "$CONFIGSOURCE" before restarting." # bashio::exit.nok fi @@ -34,7 +34,7 @@ chmod -R 755 "$(dirname "${CONFIGSOURCE}")" # Check if yaml is valid EXIT_CODE=0 -yamllint -d relaxed $CONFIGSOURCE &>ERROR || EXIT_CODE=$? +yamllint -d relaxed "$CONFIGSOURCE" &>ERROR || EXIT_CODE=$? if [ $EXIT_CODE = 0 ]; then echo "Config file is a valid yaml" else @@ -47,19 +47,21 @@ fi # Helper function function parse_yaml { local prefix=$2 || local prefix="" + # spellcheck disable=SC2155 local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @ | tr @ '\034') sed -ne "s|^\($s\):|\1|" \ -e "s| #.*$||g" \ -e "s|#.*$||g" \ + # spellcheck disable=SC1087 -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \ - -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | + -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" "$1" | awk -F$fs '{ indent = length($1)/2; vname[indent] = $2; for (i in vname) {if (i > indent) {delete vname[i]}} if (length($3) > 0) { vn=""; for (i=0; i/dev/null || true