From bad41f3f4784294b5176e677b442dc1ac12b078e Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Mon, 5 Feb 2024 02:36:45 +0100 Subject: [PATCH] Adopt 'empty' as default value for shell vars, converted to JSON null is necessary --- out | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/out b/out index 23b03d1..cdcbe5d 100755 --- a/out +++ b/out @@ -115,7 +115,7 @@ for channel in ${channels}; do if [[ "${always_notify}" != "true" && -z "${TEXT_FILE_CONTENT}" && -n "${text_file}" ]]; then text_interpolated="" else - if [[ "${attachments}" == "null" ]]; then + if [[ -z "${attachments}" ]]; then TEXT_FILE_CONTENT=${TEXT_FILE_CONTENT:-"_(no notification provided)_"} fi @@ -124,7 +124,7 @@ for channel in ${channels}; do if [[ -z "${text_interpolated}" ]]; then text_interpolated="_(missing notification text)_" if [[ -n "${attachments}" ]]; then - text_interpolated="null" + text_interpolated="" fi fi @@ -138,18 +138,18 @@ for channel in ${channels}; do --arg "text_interpolated" "${text_interpolated}" \ --arg "username" "${username}" \ --argjson "link_names" "${link_names}" \ - --arg "icon_url" "${icon_url}" \ - --arg "icon_emoji" "${icon_emoji}" \ - --arg "channel" "${channel}" \ - --arg "attachments" "${attachments}" \ + --arg "icon_url" "${icon_url}" \ + --arg "icon_emoji" "${icon_emoji}" \ + --arg "channel" "${channel}" \ + --arg "attachments" "${attachments}" \ '{ - text: $text_interpolated, - username: $username // null, + text: $text_interpolated // null, + username: $username // null, link_names: $link_names, - icon_url: $icon_url // null, - icon_emoji: $icon_emoji // null, - channel: $channel // null, - attachments: $attachments // null + icon_url: $icon_url // null, + icon_emoji: $icon_emoji // null, + channel: $channel // null, + attachments: $attachments // null }' )