11#! /bin/sh
22# Copyright 2008 Lukas Sandström <[email protected] >33#
4- # AppendPatch - A script to be used together with ExternalEditor
4+ # AppendPatch - A script to be used together with ExternalEditorRevived
55# for Mozilla Thunderbird to properly include patches inline in e-mails.
66
7- # ExternalEditor can be downloaded at http://globs.org/articles.php?lng=en&pg=2
7+ # ExternalEditorRevived extension can be installed using the Add-ons
8+ # manager in thunderbird, the source is available at
9+ # https://github.com/Frederick888/external-editor-revived
810
911CONFFILE=~ /.appprc
1012
11- SEP=" -=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-"
1213if [ -e " $CONFFILE " ] ; then
1314 LAST_DIR=$( grep -m 1 " ^LAST_DIR=" " ${CONFFILE} " | sed -e ' s/^LAST_DIR=//' )
1415 cd " ${LAST_DIR} "
2526
2627cd - > /dev/null
2728
29+ # The headers are separated from the message body by a blanks
30+ # line. However the message uses CR LF line ending so on platforms
31+ # where the native line ending is LF we see a line with a single CR.
32+ SEP=" $( printf ' ^\r\\{0,1\\}$' ) "
2833SUBJECT=$( sed -n -e ' /^Subject: /p' " ${PATCH} " )
29- HEADERS=$( sed -e ' /^ ' " ${SEP} " ' $/ ,$d' $1 )
34+ HEADERS=$( sed -e " / ${SEP} / " ' ,$d' $1 )
3035BODY=$( sed -e " 1,/${SEP} /d" $1 )
3136CMT_MSG=$( sed -e ' 1,/^$/d' -e ' /^---$/,$d' " ${PATCH} " )
3237DIFF=$( sed -e ' 1,/^---$/d' " ${PATCH} " )
@@ -37,7 +42,7 @@ CCS=$(printf '%s\n%s\n' "$CMT_MSG" "$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp
3742echo " $SUBJECT " > $1
3843echo " Cc: $CCS " >> $1
3944echo " $HEADERS " | sed -e ' /^Subject: /d' -e ' /^Cc: /d' >> $1
40- echo " $SEP " >> $1
45+ echo >> $1
4146
4247echo " $CMT_MSG " >> $1
4348echo " ---" >> $1
0 commit comments