aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--commands/msg/pipe.go25
-rw-r--r--doc/aerc.1.scd8
3 files changed, 19 insertions, 15 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 74cb6999..96856337 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,6 +38,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `:save -a` now works with multiple attachments with the same filename
- `:open` uses the attachment extension for temporary files, if possible
- memory leak when using notmuch with threading
+- `:pipe <cmd>` now executes `sh -c "<cmd>"` as indicated in the man page.
### Changed
diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go
index d37ab0ff..e972b133 100644
--- a/commands/msg/pipe.go
+++ b/commands/msg/pipe.go
@@ -7,6 +7,7 @@ import (
"os/exec"
"regexp"
"sort"
+ "strings"
"time"
"git.sr.ht/~rjarry/aerc/commands"
@@ -17,10 +18,10 @@ import (
)
type Pipe struct {
- Background bool `opt:"-b"`
- Full bool `opt:"-m"`
- Part bool `opt:"-p"`
- Cmd []string `opt:"..."`
+ Background bool `opt:"-b"`
+ Full bool `opt:"-m"`
+ Part bool `opt:"-p"`
+ Cmd string `opt:"..."`
}
func init() {
@@ -39,6 +40,7 @@ func (p Pipe) Execute(aerc *widgets.Aerc, args []string) error {
if p.Full && p.Part {
return errors.New("-m and -p are mutually exclusive")
}
+ name, _, _ := strings.Cut(p.Cmd, " ")
provider := aerc.SelectedTabContent().(widgets.ProvidesMessage)
if !p.Full && !p.Part {
@@ -53,7 +55,8 @@ func (p Pipe) Execute(aerc *widgets.Aerc, args []string) error {
}
doTerm := func(reader io.Reader, name string) {
- term, err := commands.QuickTerm(aerc, p.Cmd, reader)
+ cmd := []string{"sh", "-c", p.Cmd}
+ term, err := commands.QuickTerm(aerc, cmd, reader)
if err != nil {
aerc.PushError(err.Error())
return
@@ -62,7 +65,7 @@ func (p Pipe) Execute(aerc *widgets.Aerc, args []string) error {
}
doExec := func(reader io.Reader) {
- ecmd := exec.Command(p.Cmd[0], p.Cmd[1:]...)
+ ecmd := exec.Command("sh", "-c", p.Cmd)
pipe, err := ecmd.StdinPipe()
if err != nil {
return
@@ -82,11 +85,11 @@ func (p Pipe) Execute(aerc *widgets.Aerc, args []string) error {
} else {
if ecmd.ProcessState.ExitCode() != 0 {
aerc.PushError(fmt.Sprintf(
- "%s: completed with status %d", p.Cmd[0],
+ "%s: completed with status %d", name,
ecmd.ProcessState.ExitCode()))
} else {
aerc.PushStatus(fmt.Sprintf(
- "%s: completed with status %d", p.Cmd[0],
+ "%s: completed with status %d", name,
ecmd.ProcessState.ExitCode()), 10*time.Second)
}
}
@@ -106,7 +109,7 @@ func (p Pipe) Execute(aerc *widgets.Aerc, args []string) error {
} else {
doTerm(reader,
fmt.Sprintf("%s <%s",
- p.Cmd[0], title))
+ name, title))
}
})
return nil
@@ -181,7 +184,7 @@ func (p Pipe) Execute(aerc *widgets.Aerc, args []string) error {
if p.Background {
doExec(reader)
} else {
- doTerm(reader, fmt.Sprintf("%s <%s", p.Cmd[0], title))
+ doTerm(reader, fmt.Sprintf("%s <%s", name, title))
}
}()
} else if p.Part {
@@ -198,7 +201,7 @@ func (p Pipe) Execute(aerc *widgets.Aerc, args []string) error {
doExec(reader)
} else {
name := fmt.Sprintf("%s <%s/[%d]",
- p.Cmd[0], part.Msg.Envelope.Subject, part.Index)
+ name, part.Msg.Envelope.Subject, part.Index)
doTerm(reader, name)
}
})
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd
index b2123a54..bb1ea2d8 100644
--- a/doc/aerc.1.scd
+++ b/doc/aerc.1.scd
@@ -247,10 +247,10 @@ message list, the message in the message viewer, etc).
Moves the selected message to the target folder.
*:pipe* [*-bmp*] _<cmd>_
- Downloads and pipes the selected message into the given shell command, and
- opens a new terminal tab to show the result. By default, the selected
- message part is used in the message viewer and the full message is used in
- the message list.
+ Downloads and pipes the selected message into the given shell command
+ (executed with _sh -c "<cmd>"_), and opens a new terminal tab to show
+ the result. By default, the selected message part is used in the message
+ viewer and the full message is used in the message list.
Operates on multiple messages when they are marked. When piping multiple
messages, aerc will write them with mbox format separators.