aboutsummaryrefslogtreecommitdiffstats
path: root/commands/commands.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-06-20 22:25:47 +0200
committerRobin Jarry <robin@jarry.cc>2023-06-20 22:51:43 +0200
commit709eafda087f1f4779265e54484906c92b23b3be (patch)
tree73831b589555887d2d925ecd15792e9613cf5fda /commands/commands.go
parent8e0cc222e2c978fc2faf5825af7f26f72475369d (diff)
downloadaerc-709eafda087f1f4779265e54484906c92b23b3be.tar.gz
commands: fix panic in template execution
Fix a panic in the template execution when the template evalutes to nil. Check for length of returned arguments after the template code is expanded. To reproduce, run :{{exec "cat > /dev/null" .MessageId}} Fixes: 42cd4157 ("commands: execute commands with templates") Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/commands.go')
-rw-r--r--commands/commands.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/commands/commands.go b/commands/commands.go
index 59f87321..9366be9c 100644
--- a/commands/commands.go
+++ b/commands/commands.go
@@ -125,6 +125,9 @@ func (cmds *Commands) ExecuteCommand(
if err != nil {
return err
}
+ if len(args) == 0 {
+ return errors.New("Expected a command after template evaluation.")
+ }
if cmd, ok := cmds.dict()[args[0]]; ok {
log.Tracef("executing command %v", args)
return cmd.Execute(aerc, args)