From 42056b4c5f58ddd27c1c5a4a2f2ae324c9cd4af5 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jul 31 2011 01:59:52 +0000 Subject: Update `cli_getConfigLines.sh': - Remove verification related to section name. This imposses a limit in the amount of section names configuration files might have. Don't restrict such thing here, do it when you process the configuration lines instead using the following construction: BRANDING_CONF_VALUES=$(\ for BRANDING_CONF_SECTION in $(echo "sectionName1 sectionName2 ...");do cli_getConfigValue "${BRANDING_CONF_FILE}" "${BRANDING_CONF_SECTION}" "${BRANDING_CONF_VARNAME}" done) - Rectify verification related to variable name. - Rename variable name from MANUAL_CONFIG_FILE to CONFIG_ABSPATH. The MANUAL_CONFIG_FILE variable isn't defined in this function, so it outputs an empty value and with it makes `cat' to wait for an input. To prevent this, use the correct variable name definition (i.e., CONFIG_ABSPATH). - Force the value stored in CONFIG_VARNAME to start at the beginning of line when looked up inside CONFIG_ABSPATH. Only those values that match will be returned. --- diff --git a/Scripts/Functions/cli_getConfigLines.sh b/Scripts/Functions/cli_getConfigLines.sh index 3e974b7..81c010d 100755 --- a/Scripts/Functions/cli_getConfigLines.sh +++ b/Scripts/Functions/cli_getConfigLines.sh @@ -37,32 +37,25 @@ function cli_getConfigLines { # we want to to retrive is set in. local CONFIG_SECTION="$2" - # Verify configuration section name. Be sure it is one of the - # supported values. - if [[ ! $CONFIG_SECTION =~ '^(main|templates)$' ]];then - CONFIG_SECTION='main' - fi - # Initialize variable name we want to retrive value from. local CONFIG_VARNAME="$3" # Verify configuration variable name. When no variable name is - # provided print all configuration lines. Be sure configuration - # variable name starts just at the begining of the line. - if [[ ! $CONFIG_VARNAME =~ '^[[:alnum:]_/-\.]+$' ]];then - CONFIG_VARNAME='^[[:alnum:]_/-\.]+=' - else - CONFIG_VARNAME="^${CONFIG_VARNAME}" + # provided print all configuration lines that can be considered + # as well-formed paths. Be sure configuration variable name starts + # just at the begining of the line. + if [[ ! $CONFIG_VARNAME =~ '^[[:alnum:]_./-]+$' ]];then + CONFIG_VARNAME='[[:alnum:]_./-]+=' fi # Retrive configuration lines from configuration file. - local CONFIG_LINES=$(cat ${MANUAL_CONFIG_FILE} \ + local CONFIG_LINES=$(cat ${CONFIG_ABSPATH} \ | egrep -v '^#' \ | egrep -v '^[[:space:]]*$' \ | sed -r 's![[:space:]]*!!g' \ | sed -r -n "/^\[${CONFIG_SECTION}\]$/,/^\[/p" \ | egrep -v '^\[' | sort | uniq \ - | egrep "${CONFIG_VARNAME}") + | egrep "^${CONFIG_VARNAME}") # Output value related to variable name. echo "$CONFIG_LINES"