From 0086c8c16a93c1ff350e41e7a53d37cf57e93535 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 7 Oct 2017 15:06:00 +0200 Subject: [PATCH] [fix] match_string: unbound variable (#379) * [fix] match_string: unbound variable * Define local variables at beginning of function --- data/helpers.d/string | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/data/helpers.d/string b/data/helpers.d/string index adfdf89f..fbf59873 100644 --- a/data/helpers.d/string +++ b/data/helpers.d/string @@ -21,7 +21,10 @@ ynh_string_random() { # references to sub-expressions can be used # (see sed manual page for more information) ynh_replace_string () { - delimit=@ + local delimit=@ + local match_string=$1 + local replace_string=$2 + local workfile=$3 # Escape any backslash to preserve them as simple backslash. match_string=${match_string//\\/"\\\\"} @@ -32,10 +35,8 @@ ynh_replace_string () { replace_string=${replace_string//&/"\&"} # Escape the delimiter if it's in the string. - match_string=${1//${delimit}/"\\${delimit}"} - replace_string=${2//${delimit}/"\\${delimit}"} - - workfile=$3 + match_string=${match_string//${delimit}/"\\${delimit}"} + replace_string=${replace_string//${delimit}/"\\${delimit}"} sudo sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$workfile" }