Skip to content

Commit

Permalink
Use default shell instead of bash for running commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Dec 24, 2024
1 parent 5ca4a7c commit b1460da
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/ansible-language-server/src/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export function withInterpreter(
});

if (activationScript) {
command = `bash -c 'source ${activationScript} && ${executable} ${args}'`;
// keep it sh as this can be either bash or zsh
command = `sh -c 'source ${activationScript} && ${executable} ${args}'`;
return { command: command, env: process.env };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("withInterpreter", () => {
interpreterPath: "",
activationScript: "/path/to/venv/bin/activate",
expectedCommand:
"bash -c 'source /path/to/venv/bin/activate && ansible-lint playbook.yml'",
"sh -c 'source /path/to/venv/bin/activate && ansible-lint playbook.yml'",
expectedEnv: {},
},
{
Expand Down
3 changes: 2 additions & 1 deletion src/features/ansibleTox/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export async function getToxEnvs(
)) as string;

if (activationScript) {
command = `bash -c 'source ${activationScript} && ${command}'`;
// keep it sh as this can be either bash or zsh
command = `sh -c 'source ${activationScript} && ${command}'`;
}
if (interpreterPath && interpreterPath !== "") {
const virtualEnv = path.resolve(interpreterPath, "../..");
Expand Down
3 changes: 2 additions & 1 deletion src/features/utils/commandRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export function withInterpreter(

const activationScript = settings.activationScript;
if (activationScript) {
command = `bash -c 'source ${activationScript} && ${runExecutable} ${cmdArgs}'`;
// keep it sh as this can be either bash or zsh
command = `sh -c 'source ${activationScript} && ${runExecutable} ${cmdArgs}'`;
return { command: command, env: process.env };
}

Expand Down

0 comments on commit b1460da

Please sign in to comment.