@@ -2,25 +2,14 @@ package util
8 tea "charm.land/bubbletea/v2"
6 tea "charm.land/bubbletea/v2"
9− "mvdan.cc/sh/v3/shell"
7+ "github.com/charmbracelet/crush/internal/uiutil"
12// ExecShell parses a shell command string and executes it with exec.Command.
10// ExecShell parses a shell command string and executes it with exec.Command.
13// Uses shell.Fields for proper handling of shell syntax like quotes and
11// Uses shell.Fields for proper handling of shell syntax like quotes and
14// arguments while preserving TTY handling for terminal editors.
12// arguments while preserving TTY handling for terminal editors.
15func ExecShell(ctx context.Context, cmdStr string, callback tea.ExecCallback) tea.Cmd {
13func ExecShell(ctx context.Context, cmdStr string, callback tea.ExecCallback) tea.Cmd {
16− fields, err := shell.Fields(cmdStr, nil)
14+ return uiutil.ExecShell(ctx, cmdStr, callback)
18− return ReportError(err)
20− if len(fields) == 0 {
21− return ReportError(errors.New("empty command"))
24− cmd := exec.CommandContext(ctx, fields[0], fields[1:]...)
25− return tea.ExecProcess(cmd, callback)