From b1460dad842461b23193261d597bdbda9be2f11d Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 24 Dec 2024 10:53:47 +0000 Subject: [PATCH] Use default shell instead of bash for running commands --- packages/ansible-language-server/src/utils/misc.ts | 3 ++- .../ansible-language-server/test/utils/withInterpreter.test.ts | 2 +- src/features/ansibleTox/runner.ts | 3 ++- src/features/utils/commandRunner.ts | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/ansible-language-server/src/utils/misc.ts b/packages/ansible-language-server/src/utils/misc.ts index 1bcef4bb5..30001446e 100644 --- a/packages/ansible-language-server/src/utils/misc.ts +++ b/packages/ansible-language-server/src/utils/misc.ts @@ -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 }; } diff --git a/packages/ansible-language-server/test/utils/withInterpreter.test.ts b/packages/ansible-language-server/test/utils/withInterpreter.test.ts index 42c312fce..255673c6d 100644 --- a/packages/ansible-language-server/test/utils/withInterpreter.test.ts +++ b/packages/ansible-language-server/test/utils/withInterpreter.test.ts @@ -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: {}, }, { diff --git a/src/features/ansibleTox/runner.ts b/src/features/ansibleTox/runner.ts index 946dadaa9..7dc8ee38e 100644 --- a/src/features/ansibleTox/runner.ts +++ b/src/features/ansibleTox/runner.ts @@ -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, "../.."); diff --git a/src/features/utils/commandRunner.ts b/src/features/utils/commandRunner.ts index 9c75b8881..2881c3eca 100644 --- a/src/features/utils/commandRunner.ts +++ b/src/features/utils/commandRunner.ts @@ -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 }; }