From 4257a5292af5a9a3ff8fbbc76a00fdeffc75bfd2 Mon Sep 17 00:00:00 2001 From: Ori Bernstein Date: Fri, 6 Nov 2020 18:15:15 -0800 Subject: [PATCH] upas/marshal: add -S saveto to save outgoing mail, fix -F Upas/marshal -F was broken with the '-8' command, and silly without it: It used aliases passed on the command line, so the destination address was ignored with -8 was passed. In addition, it would create a new mailbox for any aliases being sent to, instead of putting them all in one location. The new -S option is similar to -F, but specifies where the message should go. --- sys/man/1/marshal | 8 ++++++++ sys/src/cmd/upas/marshal/marshal.c | 14 +++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/sys/man/1/marshal b/sys/man/1/marshal index ef654a1fb..e2fc8336c 100644 --- a/sys/man/1/marshal +++ b/sys/man/1/marshal @@ -15,6 +15,9 @@ marshal \- formatting and sending mail ] [ .B -Fr#xn ] [ +.B -S +.I saveto +] [ .B -p[es] ] [ .B -R @@ -104,6 +107,11 @@ as a recipient. .BI -F file the message .TP +.BI -S saveto +file the message into the +.I saveto +mailbox. +.TP .BI -n intentionally no standard input .TP diff --git a/sys/src/cmd/upas/marshal/marshal.c b/sys/src/cmd/upas/marshal/marshal.c index c40e3cfd6..3e26d9dbf 100644 --- a/sys/src/cmd/upas/marshal/marshal.c +++ b/sys/src/cmd/upas/marshal/marshal.c @@ -193,7 +193,7 @@ void main(int argc, char **argv) { int ccargc, bccargc, flags, fd, noinput, headersrv; - char *subject, *type, *boundary; + char *subject, *type, *boundary, *saveto; char *ccargv[32], *bccargv[32]; Addr *to, *cc, *bcc; Attach *first, **l, *a; @@ -207,6 +207,7 @@ main(int argc, char **argv) l = &first; type = nil; hdrstring = nil; + saveto = nil; ccargc = bccargc = 0; tmfmtinstall(); @@ -244,6 +245,9 @@ main(int argc, char **argv) case 'F': Fflag = 1; /* file message */ break; + case 'S': + saveto = EARGF(usage()); + break; case 'n': /* no standard input */ nflag = 1; break; @@ -336,7 +340,9 @@ main(int argc, char **argv) } } - fd = sendmail(to, cc, bcc, &pid, Fflag ? argv[0] : nil); + if(Fflag) + saveto=argc>0?argv[0]:to->v; + fd = sendmail(to, cc, bcc, &pid, saveto); if(fd < 0) sysfatal("execing sendmail: %r\n:"); if(xflag || lbflag || dflag){ @@ -1079,10 +1085,8 @@ sendmail(Addr *to, Addr *cc, Addr *bcc, int *pid, char *rcvr) break; case 0: close(pfd[0]); - b = 0; /* BOTCH; "From " time gets changed */ - if(rcvr) - b = openfolder(foldername(nil, user, rcvr), time(0)); + b = openfolder(foldername(nil, user, rcvr), time(0)); fd = b? Bfildes(b): -1; printunixfrom(fd); tee(0, pfd[1], fd);