From 1e7da3c8831bab641c93c568ea0efa1524e232eb Mon Sep 17 00:00:00 2001 From: C-Duv Date: Sun, 5 Feb 2017 02:13:09 +0100 Subject: [PATCH] Use variable mangling to strip last \n from message Due to how stdin is read, the message gets a trailing "\n". sed was used to remove it but this commit use shell variable mangling "${var%Pattern}" instead (faster and nicer). --- send-notification.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/send-notification.sh b/send-notification.sh index 6dcc915..c3a1f35 100644 --- a/send-notification.sh +++ b/send-notification.sh @@ -60,7 +60,7 @@ else # Message lu de STDIN do MESSAGE_TO_SEND="$MESSAGE_TO_SEND$line\n" done - MESSAGE_TO_SEND=$(echo $MESSAGE_TO_SEND | sed 's/\n$//') # Retire le dernier saut de ligne + MESSAGE_TO_SEND=${MESSAGE_TO_SEND%"\n"} # Retire le dernier saut de ligne fi FINAL_MESSAGE_TO_SEND="$MESSAGE_HEADER$MESSAGE_TO_SEND$MESSAGE_FOOTER" # Assemble header, message et footer