Skip to content

Commit

Permalink
main: detect invalid arguments early
Browse files Browse the repository at this point in the history
Currently, when running aerc --help or aerc --version, we get an obscure
error when aerc is already running.

	$ aerc --help
	response: command not understood

When it is not running, it starts but prints the same error message in
the status line with weird colors.

Avoid sending garbage into the control socket. Try to detect invalid
arguments early.

	$ aerc --foobaz
	error: unknown argument: --foobaz

Reported-by: Peter Sanchez <[email protected]>
Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Bence Ferdinandy <[email protected]>
  • Loading branch information
rjarry committed Jun 28, 2024
1 parent 7c5a1af commit 8e1f1dc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ func main() {
if err != nil {
die("%s", err)
}
switch {
case len(opts.Command) == 0:
break
case strings.HasPrefix(opts.Command[0], ":"):
case strings.HasPrefix(opts.Command[0], "mailto:"):
case strings.HasPrefix(opts.Command[0], "mbox:"):
break
default:
die("unknown argument: %s", opts.Command[0])
}

err = config.LoadConfigFromFile(
nil, opts.Accounts, opts.ConfAerc, opts.ConfBinds, opts.ConfAccounts,
Expand Down

0 comments on commit 8e1f1dc

Please sign in to comment.