[Bug 289908] mail(1) "inc" + "save" command creates malformed mbox file it can't re-open properly

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 30 Sep 2025 18:11:41 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=289908

--- Comment #1 from Tim Chase <freebsd@tim.thechases.com> ---
I've further narrowed this down to just `inc` corrupting things:

  $ echo body1 | mail -s test1 $USER
  $ mail
  & set hold

and in another window

  $ echo body2 | mail -s test2 $USER

then back in the first window, incorporate the new message

  & inc

At this point, it correctly identifies two messages in the mailbox:

  & h

Modify the mailbox (in this case by reading a message changes the read-flag)

  & 2
  & q

Quitting re-writes the $MAIL file (/var/mail/$USER) without the space between
the two messages so that re-opening the mailbox causes the two messages to be
merged into one:

  $ mail

only shows one message, and when displayed, has the body of "test1"
concatenated with the headers of "test2" followed by "body2".

-- 
You are receiving this mail because:
You are the assignee for the bug.