diff options
author | Robin Jarry <robin@jarry.cc> | 2023-09-24 21:10:19 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-10-28 19:25:02 +0200 |
commit | 1db74a9ba74350776dee5f2384744357ad3aace5 (patch) | |
tree | 923e7ef487ee71876620d4f8370b06a543f5fb79 /config | |
parent | 8464b373851142b0becaaa10db34df3559b2b62e (diff) | |
download | aerc-1db74a9ba74350776dee5f2384744357ad3aace5.tar.gz |
open: run commands with sh -c
Allow running shell commands in openers.
Changelog-changed: `:open` commands are now executed with `sh -c`.
Requested-by: Vitaly Ovchinnikov <v@postbox.nz>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Tested-by: Inwit <inwit@sindominio.net>
Diffstat (limited to 'config')
-rw-r--r-- | config/aerc.conf | 9 | ||||
-rw-r--r-- | config/openers.go | 13 |
2 files changed, 7 insertions, 15 deletions
diff --git a/config/aerc.conf b/config/aerc.conf index 18c6decc..06cfb2d1 100644 --- a/config/aerc.conf +++ b/config/aerc.conf @@ -548,9 +548,10 @@ message/rfc822=colorize # actions on a per-MIME-type basis. The :open-link URL scheme is used to # determine the MIME type as follows: x-scheme-handler/<scheme>. # -# {} is expanded as the temporary filename to be opened. If it is not -# encountered in the command, the temporary filename will be appened to the end -# of the command. +# {} is expanded as the temporary filename or URL to be opened with proper +# shell quoting. If it is not encountered in the command, the filename/URL will +# be appended to the end of the command. The command will then be executed with +# `sh -c`. # # Like [filters], openers support basic shell globbing. The first opener which # matches the part's MIME type (or URL scheme handler MIME type) will be used, @@ -558,7 +559,7 @@ message/rfc822=colorize # # Examples: # x-scheme-handler/irc=hexchat -# x-scheme-handler/http*=firefox +# x-scheme-handler/http*=printf '%s' {} | wl-copy # text/html=surf -dfgms # text/plain=gvim {} +125 # message/rfc822=thunderbird diff --git a/config/openers.go b/config/openers.go index e246ea64..31d99e9c 100644 --- a/config/openers.go +++ b/config/openers.go @@ -1,17 +1,15 @@ package config import ( - "fmt" "strings" "git.sr.ht/~rjarry/aerc/log" "github.com/go-ini/ini" - "github.com/google/shlex" ) type Opener struct { Mime string - Args []string + Args string } var Openers []Opener @@ -24,14 +22,7 @@ func parseOpeners(file *ini.File) error { for _, key := range openers.Keys() { mime := strings.ToLower(key.Name()) - if args, err := shlex.Split(key.Value()); err != nil { - return err - } else { - if len(args) == 0 { - return fmt.Errorf("opener command empty for %s", mime) - } - Openers = append(Openers, Opener{Mime: mime, Args: args}) - } + Openers = append(Openers, Opener{Mime: mime, Args: key.Value()}) } out: |