From 2b46f0cefe4cda681ebfdc838fede37e7e5dc893 Mon Sep 17 00:00:00 2001 From: Andrewcodess Date: Mon, 24 Aug 2026 00:42:21 +0530 Subject: [PATCH] fix: prevent shell options from environment variables --- docs/cli.md | 5 ++--- docs/shell.md | 6 +----- src/core.ts | 3 --- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/docs/cli.md b/docs/cli.md index efcb80cf6b..460b4f1a96 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -163,10 +163,10 @@ Print the current `zx` version. Print help notes. ## Environment variables -All the previously mentioned options can be set via the corresponding `ZX_`-prefixed environment variables. +Most options can be set via the corresponding `ZX_`-prefixed environment variables. For security reasons, `shell`, `prefix`, and `postfix` cannot be set via environment variables. ```bash -ZX_VERBOSE=true ZX_SHELL='/bin/bash' zx script.mjs +ZX_VERBOSE=true zx script.mjs ``` ```yaml @@ -175,7 +175,6 @@ steps: run: zx script.mjs env: ZX_VERBOSE: true - ZX_SHELL: '/bin/bash' ``` ## `__filename & __dirname` diff --git a/docs/shell.md b/docs/shell.md index e10e189078..757c411e10 100644 --- a/docs/shell.md +++ b/docs/shell.md @@ -35,7 +35,7 @@ There're many shell implementations. zx brings a few setup helpers: * [`usePowerShell`](./api#usepowershell) — PowerShell * [`usePwsh`](./api#usepwsh) — pwsh (PowerShell v7+) -You can also set the shell directly via [JS API](./setup#bash), [CLI flags](./cli#shell) or [envars](./cli#environment-variables): +You can also set the shell directly via [JS API](./setup#bash) or [CLI flags](./cli#shell): ```js $.shell = '/bin/zsh' @@ -45,9 +45,5 @@ $.shell = '/bin/zsh' zx --shell /bin/zsh script.js ``` -```bash -ZX_SHELL=/bin/zsh zx script.js -``` - ## zx = bash + js No compromise, take the best of both. diff --git a/src/core.ts b/src/core.ts index 39c320149f..3ec2087710 100644 --- a/src/core.ts +++ b/src/core.ts @@ -84,9 +84,6 @@ const ENV_OPTS: Set = new Set([ 'timeout', 'timeoutSignal', 'killSignal', - 'prefix', - 'postfix', - 'shell', ]) // prettier-ignore