Skip to content

Commit

Permalink
Allow printf to be more flexible with slack message content.
Browse files Browse the repository at this point in the history
- 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!!
  • Loading branch information
Jackman3005 committed Feb 9, 2017
1 parent 0cf7971 commit ddb6836
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions out
Original file line number Diff line number Diff line change
Expand Up @@ -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 .)"

Expand Down

0 comments on commit ddb6836

Please sign in to comment.