Skip to content

Commit

Permalink
gok edit: run $EDITOR/$VISUAL through /bin/sh -c
Browse files Browse the repository at this point in the history
This makes command line arguments in these environment variables work,
e.g. 'code -w', or 'emacs -q'

fixes gokrazy/gokrazy#217
  • Loading branch information
stapelberg committed Sep 21, 2023
1 parent 23cde3b commit 231dea4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions internal/gok/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"syscall"

Expand Down Expand Up @@ -52,9 +51,6 @@ func (r *editImplConfig) run(ctx context.Context, args []string, stdout, stderr
if editor == "" {
editor = "vi" // most likely available
}
absEditor, err := exec.LookPath(editor)
if err != nil {
return err
}
return syscall.Exec(absEditor, []string{absEditor, configJSON}, os.Environ())
shellCmd := fmt.Sprintf("%s %q", editor, configJSON)
return syscall.Exec("/bin/sh", []string{"/bin/sh", "-c", shellCmd}, os.Environ())
}

0 comments on commit 231dea4

Please sign in to comment.