diff options
author | Jorge Hernandez <jh1730@att.com> | 2017-08-04 16:26:24 -0500 |
---|---|---|
committer | Jorge Hernandez <jh1730@att.com> | 2017-08-04 16:26:24 -0500 |
commit | dc4ffa2b8d51ec96a7032db5c619eb991862322e (patch) | |
tree | bbf119e122b3809df52cf71d9e97f149fb03d0de /policy-drools | |
parent | 21e0f0079894c855266a7a41bcb1a73403641302 (diff) |
[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 <jh1730@att.com>
Diffstat (limited to 'policy-drools')
-rw-r--r-- | policy-drools/docker-install.sh | 9 |
1 files 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" |