From 673ae1bbc760ad96664e84d54d373839d9ae2c57 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Thu, 15 Feb 2024 15:35:25 -0500 Subject: ipc: accept verbatim commands When aerc receives a command over IPC, it quotes the arguments before passing them on to the internal command parser. In many cases, the parser interprets the quotes, and the command runs with the arguments exactly as they were specified in the shell. In some cases, though, the quotes are not interpreted and the additional quotes can cause the command to fail. Simply eliminating the addition of quotes is not possible because some commands need them. Allow a command and its arguments to be specified as a single argument in the shell. In that case, pass that argument verbatim to the internal command parser so that it is interpreted exactly as if it had been typed directly in aerc's command line. Link: https://lists.sr.ht/~rjarry/aerc-devel/%3C20240203085541.27416-2-contact%40willowbarraco.fr%3E Changelog-added: Execute IPC commands verbatim by providing the command and its args as a single argument in the shell. Cc: Willow Barraco Signed-off-by: Jason Cox Acked-by: Robin Jarry --- lib/ipc/receive.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/ipc') diff --git a/lib/ipc/receive.go b/lib/ipc/receive.go index e2fffaf0..79618f50 100644 --- a/lib/ipc/receive.go +++ b/lib/ipc/receive.go @@ -128,8 +128,11 @@ func (as *AercServer) handleMessage(req *Request) *Response { Error: "command rejected: IPC is disabled", } } - cmdline := opt.QuoteArgs(req.Arguments...) - err = as.handler.Command(cmdline.String()) + cmdline := req.Arguments[0] + if len(req.Arguments) > 1 { + cmdline = opt.QuoteArgs(req.Arguments...).String() + } + err = as.handler.Command(cmdline) if err != nil { return &Response{Error: err.Error()} } -- cgit