about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--mexport.c3
-rwxr-xr-xt/1800-mexport.t26
2 files changed, 29 insertions, 0 deletions
diff --git a/mexport.c b/mexport.c
index d758d0c..27dc40f 100644
--- a/mexport.c
+++ b/mexport.c
@@ -125,6 +125,9 @@ export(char *file)
 	if (!final_nl)
 		putchar('\n');
 
+	// ensure empty line at end of message
+	putchar('\n');
+
 	fclose(infile);
 }
 
diff --git a/t/1800-mexport.t b/t/1800-mexport.t
new file mode 100755
index 0000000..c0eadbd
--- /dev/null
+++ b/t/1800-mexport.t
@@ -0,0 +1,26 @@
+#!/bin/sh -e
+cd ${0%/*}
+. ./lib.sh
+plan 2
+
+cat <<EOF >tmp.1
+Subject: message 1
+
+This is message 1.
+EOF
+
+cat <<EOF >tmp.2
+Subject: message 2
+
+This is message 2.  It has a trailing empty line.
+
+EOF
+
+printf >tmp.3 'Subject: message 3
+
+This is message 3.  It has a no trailing newline, oops.'
+
+mexport ./tmp.1 ./tmp.2 ./tmp.3 >./tmp.mbox
+
+check 'generated mbox has 16 lines' 'cat ./tmp.mbox | wc -l | grep 16'
+check 'generated mbox has 7 empty lines' 'grep -c "^$" ./tmp.mbox | grep 7'