From 6a87d8be721d4fc371844c71cc4ecc2d85b01c79 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Thu, 14 Apr 2022 12:13:44 -0500 Subject: [PATCH] forward: allow ':forward -A' with no address Allow using the command ':forward -A' without specifying an email address inline. Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- commands/msg/forward.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/commands/msg/forward.go b/commands/msg/forward.go index c8e04f1..9b234ef 100644 --- a/commands/msg/forward.go +++ b/commands/msg/forward.go @@ -41,10 +41,18 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error { } attach := false template := "" + var tolist []*mail.Address for _, opt := range opts { switch opt.Option { case 'A': attach = true + to := strings.Join(args[optind:], ", ") + if strings.Contains(to, "@") { + tolist, err = mail.ParseAddressList(to) + if err != nil { + return fmt.Errorf("invalid to address(es): %v", err) + } + } case 'T': template = opt.Value } @@ -69,12 +77,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error { subject := "Fwd: " + msg.Envelope.Subject h.SetSubject(subject) - if len(args) != 1 { - to := strings.Join(args[optind:], ", ") - tolist, err := mail.ParseAddressList(to) - if err != nil { - return fmt.Errorf("invalid to address(es): %v", err) - } + if len(tolist) > 0 { h.SetAddressList("to", tolist) }