From ddb6836f54abfda47971bbcd6caa02716cb74cd3 Mon Sep 17 00:00:00 2001 From: Jack Coy Date: Wed, 8 Feb 2017 20:54:20 -0700 Subject: [PATCH] Allow printf to be more flexible with slack message content. - I have a situation where I have a dash '-' in a url that I would like to send via a slack message. I was getting errors saying I cannot do this. - The %b format flag does this "Print the associated argument while interpreting backslash escapes in there". This allows you to keep using \n characters in your messages, but also not try to interpret any dashes as additional command line arguments!! --- out | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/out b/out index 7935e9b..3876f03 100755 --- a/out +++ b/out @@ -64,8 +64,7 @@ fi 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="$(eval printf "%b" ${text} )" [[ -z "${text}" ]] && text="_(missing notification text)_" text="$(echo "${text}" | jq -R -s .)"