From dc4ffa2b8d51ec96a7032db5c619eb991862322e Mon Sep 17 00:00:00 2001 From: Jorge Hernandez Date: Fri, 4 Aug 2017 16:26:24 -0500 Subject: [PATCH] [POLICY-145] sed failed expanding special chars The install script fails when expanding configuration variables with special characters, for example the delimiter. This fix' scope is for the replacement string escaping. Change-Id: Icfe8d89b46c7720bf5effaa2f3add6a19e2af2d2 Signed-off-by: Jorge Hernandez --- policy-drools/docker-install.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/policy-drools/docker-install.sh b/policy-drools/docker-install.sh index cedb2121..aaa3d10d 100644 --- a/policy-drools/docker-install.sh +++ b/policy-drools/docker-install.sh @@ -144,7 +144,7 @@ function configure_component() { set -x fi - local CONF_FILE COMPONENT_ROOT_DIR name value + local CONF_FILE COMPONENT_ROOT_DIR SED_LINE SED_FILES name value CONF_FILE=$1 COMPONENT_ROOT_DIR=$2 @@ -157,16 +157,15 @@ function configure_component() { SED_LINE+=" -e 's!\${{JAVA_HOME}}!${JAVA_HOME}!g' " while read line || [ -n "${line}" ]; do - if [[ -n $line ]] && [[ $line != *#* ]]; then + if [[ -n ${line} ]] && [[ ${line:0:1} != \# ]]; then name=$(echo "${line%%=*}") value=$(echo "${line#*=}") # escape ampersand so that sed does not replace it with the search string - value=${value//&/\\&} + value=$(echo "${value}" | sed -e 's/[\/&]/\\&/g') if [[ -z ${name} ]] || [[ -z ${value} ]]; then echo "WARNING: ${line} missing name or value" fi - SED_LINE+=" -e 's!\${{${name}}}!${value}!g' " - + SED_LINE+=" -e 's/\${{${name}}}/${value}/g' " fi done < "$CONF_FILE" -- 2.16.6