Run $EDITOR through the shell in config edit (closes #315)
check / check (push) Waiting to run
check / check (push) Waiting to run
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
This commit is contained in:
@@ -333,8 +333,15 @@ func newConfigEditCommand() *cobra.Command {
|
||||
editor = "vi"
|
||||
}
|
||||
|
||||
// Run $EDITOR through the shell, as git does, so a value
|
||||
// with arguments such as "code --wait" works. The path
|
||||
// goes in as an argument ("$@"), not into the command
|
||||
// text, so a path with spaces or quotes arrives whole.
|
||||
// sh -c takes the word after the command as $0, which
|
||||
// is why editor appears twice.
|
||||
//nolint:gosec // G204: launching the operator's own $EDITOR is the point
|
||||
ed := exec.CommandContext(cmd.Context(), editor, path)
|
||||
ed := exec.CommandContext(cmd.Context(),
|
||||
"sh", "-c", editor+` "$@"`, editor, path)
|
||||
ed.Stdin = os.Stdin
|
||||
ed.Stdout = os.Stdout
|
||||
ed.Stderr = os.Stderr
|
||||
|
||||
Reference in New Issue
Block a user