Run $EDITOR through the shell in config edit #380

Merged
clawbot merged 1 commits from issue-315-editor-args into next 2026-10-14 03:06:58 +02:00
Collaborator

Fixes #315.

config edit handed the whole of $EDITOR to the system as one program name, so any value with arguments (code --wait, emacsclient -t, cat -n) failed with "executable file not found in $PATH".

It now runs $EDITOR through sh the way git does: sh -c with the $EDITOR text followed by "$@", and the config path as a separate argument. The shell parses the editor text, so its arguments and any quoting in it work; the path is never written into the command text, so a path with spaces or quotes reaches the editor whole. With $EDITOR unset it still falls back to vi.

The new test sets $EDITOR to cp with a replacement file as its argument and runs config edit on a config whose file name contains a space; the config ends up with the replacement's content only if both the argument and the whole path arrived.

Judgement call: $EDITOR is now shell text, so shell metacharacters in it are interpreted, as they are for git and crontab.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/vaultik/issues/315. `config edit` handed the whole of `$EDITOR` to the system as one program name, so any value with arguments (`code --wait`, `emacsclient -t`, `cat -n`) failed with "executable file not found in $PATH". It now runs `$EDITOR` through `sh` the way git does: `sh -c` with the `$EDITOR` text followed by `"$@"`, and the config path as a separate argument. The shell parses the editor text, so its arguments and any quoting in it work; the path is never written into the command text, so a path with spaces or quotes reaches the editor whole. With `$EDITOR` unset it still falls back to `vi`. The new test sets `$EDITOR` to `cp` with a replacement file as its argument and runs `config edit` on a config whose file name contains a space; the config ends up with the replacement's content only if both the argument and the whole path arrived. Judgement call: `$EDITOR` is now shell text, so shell metacharacters in it are interpreted, as they are for git and crontab. Model: opus-5-5
clawbot added the needs-review label 2026-10-14 02:53:49 +02:00
clawbot self-assigned this 2026-10-14 02:53:49 +02:00
clawbot added 1 commit 2026-10-14 02:53:49 +02:00
config edit used the whole of $EDITOR as the program name, so a value
with arguments such as "code --wait" or "emacsclient -t" failed with
"executable file not found". It now runs $EDITOR the way git does:
sh -c '<editor> "$@"' with the config path as a separate argument, so
the editor's own arguments and quoting work and a path with spaces
reaches it whole. A test runs config edit with an $EDITOR carrying an
argument on a config path that contains a space.

Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit d8f4f62f41 into next 2026-10-14 03:06:58 +02:00
clawbot deleted branch issue-315-editor-args 2026-10-14 03:06:59 +02:00
Sign in to join this conversation.