Skip to content

Commit 4ca9599

Browse files
committed
feat: added disable auto correct for zsh shells
1 parent 3eb3c0b commit 4ca9599

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/utils/spawn.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ export async function spawnSafe(cmd: string, options?: SpawnOptions, pluginName?
8080
const initialCols = process.stdout.columns ?? 80;
8181
const initialRows = process.stdout.rows ?? 24;
8282

83-
const command = options?.requiresRoot ? `sudo -k >/dev/null 2>&1; sudo -S <<< "${password}" -E ${ShellUtils.getDefaultShell()} ${options?.interactive ? '-i' : ''} -c "${cmd.replaceAll('"', '\\"')}"` : cmd;
83+
// zsh autocorrect prompts (e.g. "zsh: correct 'config' to '.config' [nyae]?") will hang
84+
// the pty waiting for interactive input. Can't be disabled via env var; must unset the options explicitly.
85+
const disableAutocorrect = ShellUtils.getShell() === Shell.ZSH ? 'unsetopt CORRECT CORRECT_ALL 2>/dev/null; ' : '';
86+
const command = options?.requiresRoot
87+
? `sudo -k >/dev/null 2>&1; sudo -S <<< "${password}" -E ${ShellUtils.getDefaultShell()} ${options?.interactive ? '-i' : ''} -c "${(disableAutocorrect + cmd).replaceAll('"', '\\"')}"`
88+
: `${disableAutocorrect}${cmd}`;
8489
const args = options?.interactive ? ['-i', '-c', command] : ['-c', command]
8590

8691
// Run the command in a pty for interactivity

0 commit comments

Comments
 (0)