According to the POSIX definitions for mail(1) & mailx(1), the
(s)ave command should save to "mbox" if the filename is not specified

> Save the specified messages in the file named by the pathname
> file, or the mbox if the file argument is omitted

(newer spec)
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/mailx.html#tag_20_75_13_33

> s [file]
>  Save the message in the named file (mbox is default).

(older spec)
https://pubs.opengroup.org/onlinepubs/7908799/xcu/mail.html#tag_001_014_1339



However, when exercising this functionality, mail(1) on OpenBSD
(also tested on FreeBSD where the same issue manifests[1]) doesn't
support this:

  demo$ echo test | mail -s "test" demo # send self a message
  demo$ mail
  Mail version 8.1 6/6/93.  Type ? for help.
  "/var/mail/demo": 1 message 1 new
  >N  1 [email protected]  Thu Dec 15 19:34  19/775   "test"
  & s
  No file specified.

While I'm not positive on the solution, I think it involves tweaking
the save1() function in src/usr.bin/mail/cmd2.c such that instead
of failing if it can't snarf(), it should set `file` to "mbox" or
"&" so that expand() points to the mbox as required by POSIX.

-tkc

[1]
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268402





Reply via email to