You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
616 B

import { ScriptLine, define } from "./types"
import quote from "shell-escape"
type HasInSubShell = { inSubShell: (script: ScriptLine) => ScriptLine }
export const cmdInSubShell = {
bash: define<HasInSubShell>({
inSubShell: (script) => `echo ${quote([script])} | bash`,
}),
zsh: define<HasInSubShell>({
inSubShell: (script) => `echo ${quote([script])} | zsh`,
}),
fish: define<HasInSubShell>({
inSubShell: (script) => `fish -c ${quote([script])}`,
}),
powershell: define<HasInSubShell>({
inSubShell: (script) =>
`echo '${script.replace(/'/g, "\\'")}' | pwsh -NoProfile`,
}),
}