@@ -2,25 +2,14 @@ package util
22
33import (
44 "context"
5− "errors"
6− "os/exec"
75
86 tea "charm.land/bubbletea/v2"
9− "mvdan.cc/sh/v3/shell"
7+ "github.com/charmbracelet/crush/internal/uiutil"
108)
119
1210// ExecShell parses a shell command string and executes it with exec.Command.
1311// Uses shell.Fields for proper handling of shell syntax like quotes and
1412// arguments while preserving TTY handling for terminal editors.
1513func ExecShell(ctx context.Context, cmdStr string, callback tea.ExecCallback) tea.Cmd {
16− fields, err := shell.Fields(cmdStr, nil)
17− if err != nil {
18− return ReportError(err)
19− }
20− if len(fields) == 0 {
21− return ReportError(errors.New("empty command"))
22− }
23−
24− cmd := exec.CommandContext(ctx, fields[0], fields[1:]...)
25− return tea.ExecProcess(cmd, callback)
14+ return uiutil.ExecShell(ctx, cmdStr, callback)
2615}