mexport: ensure mbox entries are separated by an empty line

https://www.loc.gov/preservation/digital/formats/fdd/fdd000383.shtml
> Each message is immediately prefaced by a separation line and
> terminated by an empty line.

Bug discovered by skarnet.
pull/209/head
Leah Neukirchen 3 years ago
parent 5b52110399
commit 7d04932813

@ -125,6 +125,9 @@ export(char *file)
if (!final_nl)
putchar('\n');
// ensure empty line at end of message
putchar('\n');
fclose(infile);
}

@ -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'
Loading…
Cancel
Save