Skip to content

Commit 2c57de7

Browse files
committed
fix: Fixed environment variables not carried over to sudo. Fixed bash only sudo command.
1 parent bb604b1 commit 2c57de7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/utils/spawn.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ export async function spawnSafe(cmd: string, options?: SpawnOptions, pluginName?
6868
// Mac OS uses -SN instead of -Sn
6969
let command;
7070
if (OsUtils.isMacOS()) {
71-
command = options?.requiresRoot ? `sudo -k >/dev/null 2>&1; sudo -SN <<< "${password}" bash ${options?.interactive ? '-i' : ''} -c "${cmd.replaceAll('"', '\\"')}"` : cmd;
71+
command = options?.requiresRoot ? `sudo -k >/dev/null 2>&1; sudo -SN <<< "${password}" -E ${ShellUtils.getDefaultShell()} ${options?.interactive ? '-i' : ''} -c "${cmd.replaceAll('\'', '\\\'')}"` : cmd;
7272
} else {
73-
command = options?.requiresRoot ? `sudo -k >/dev/null 2>&1; sudo -S <<< "${password}" bash ${options?.interactive ? '-i' : ''} -c "${cmd.replaceAll('"', '\\"')}"` : cmd;
73+
command = options?.requiresRoot ? `sudo -k >/dev/null 2>&1; sudo -S <<< "${password}" -E ${ShellUtils.getDefaultShell()} ${options?.interactive ? '-i' : ''} -c '${cmd.replaceAll('\'', '\\\'')}'` : cmd;
7474
}
7575

7676
console.log(command);

0 commit comments

Comments
 (0)