On 03/04/2023 10:35, Denys Vlasenko wrote:
But it's not necessary, right? chkmail() does not actually uses
pathopts. It can just call padvance_magic(..., 0)
so as to ignore them.
chkmail() does use pathopt. It is used to customise the message that
gets printed:
if (!changed && statb.st_mtime != *mtp) {
outfmt(
&errout, snlfmt,
pathopt ? pathopt : "you have mail"
);
}
POSIX also specifies the use of '%' for this (although dash's
implementation is not entirely compatible):
MAILPATH
Provide a list of pathnames and optional messages separated by
<colon> characters. If this variable is set, the shell shall inform
the user if any of the files named by the variable are created or if
any of their modification times change. (See the preceding entry for
MAIL for descriptions of mail arrival and user informing.) Each
pathname can be followed by '%' and a string that shall be subjected
to parameter expansion and written to standard error when the
modification time changes. If a '%' character in the pathname is
preceded by a <backslash>, it shall be treated as a literal '%' in
the pathname. The default message is unspecified.
Cheers,
Harald van Dijk