fix: bd edit now parses EDITOR with args (GH#987)

Parse $EDITOR value to handle editors that need flags like
"zeditor --wait" or "code --wait". Previously the entire string
was treated as the executable name.

Fixes #987

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/dave
Rig: beads
Role: crew
This commit is contained in:
beads/crew/dave
2026-01-09 22:53:23 -08:00
committed by Steve Yegge
parent 4009fc6709
commit 279a224866

View File

@@ -130,8 +130,10 @@ Examples:
} }
_ = tmpFile.Close() _ = tmpFile.Close()
// Open the editor // Open the editor - parse command and args (handles "vim -w" or "zeditor --wait")
editorCmd := exec.Command(editor, tmpPath) //nolint:gosec // G204: editor from trusted $EDITOR/$VISUAL env or known defaults editorParts := strings.Fields(editor)
editorArgs := append(editorParts[1:], tmpPath)
editorCmd := exec.Command(editorParts[0], editorArgs...) //nolint:gosec // G204: editor from trusted $EDITOR/$VISUAL env or known defaults
editorCmd.Stdin = os.Stdin editorCmd.Stdin = os.Stdin
editorCmd.Stdout = os.Stdout editorCmd.Stdout = os.Stdout
editorCmd.Stderr = os.Stderr editorCmd.Stderr = os.Stderr