From 09690c49503e01e83ce1fcbf227fbae265f34cd8 Mon Sep 17 00:00:00 2001 From: Michael Both Date: Wed, 27 Feb 2019 23:20:10 +0100 Subject: [PATCH] Update out Use envsubst instead of eval --- bin/out | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/out b/bin/out index c8e7580..b0dce38 100755 --- a/bin/out +++ b/bin/out @@ -46,7 +46,7 @@ team="$(jq -r '.params.team // "main"' < "${payload}")" prefix="$(jq -r '.params.prefix // ""' < "${payload}")" -TEXT_FILE_CONTENT="" +export TEXT_FILE_CONTENT="" [[ -n "${text_file}" && -f "${text_file}" ]] && TEXT_FILE_CONTENT="$(cat "${text_file}")" DATA_FILE_CONTENT="" [[ -n "${data_file}" && -f "${data_file}" ]] && DATA_FILE_CONTENT="$(cat "${data_file}")" @@ -55,12 +55,12 @@ if [[ "$always_notify" == "true" || -n "$TEXT_FILE_CONTENT" || -z "$text_file" | then TEXT_FILE_CONTENT="${TEXT_FILE_CONTENT:-_(no notification provided)_}" - text="$(eval printf ${text} )" + text=$(echo -n "$text" | envsubst) [[ -z "${text}" ]] && text="_(missing notification text)_" [ "${link}" == "true" ] && formatted_body="${text}" if [ -n "$prefix" ]; then - prefix="$(eval printf ${prefix} )" + prefix=$(echo "$prefix" | envsubst) text="${prefix}: ${text}" [ -n "${formatted_body}" ] && formatted_body="${prefix}: ${formatted_body}" fi @@ -68,8 +68,8 @@ then text="$(echo -n "${text}" | jq -R -s .)" [ -n "${formatted_body}" ] && formatted_body="$(echo -n "${formatted_body}" | jq -R -s .)" - [[ "${token}" != "null" ]] && username="$(eval "printf ${token}" | jq -R -s .)" - [[ "${room_id}" != "null" ]] && room_id="$(eval "printf ${room_id}" | jq -R -s .)" + [[ "${token}" != "null" ]] && username=$(echo "$token" | envsubst | jq -R -s .)" + [[ "${room_id}" != "null" ]] && room_id=$(echo "$room_id" | envsubst | jq -R -s .)" body="$(cat <