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).
This commit is contained in:
C-Duv 2017-02-05 02:13:09 +01:00
parent 8aaf901c19
commit 1e7da3c883

View File

@ -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