Skip to content

Commit 05a825f

Browse files
fix: detect $VAR shell expansion, handle already-exited child, broaden env redaction
- Add $ and lowercase letters to SHELL_FEATURES_RE so scripts with variable references or mixed-case env assignments route through sh -c - Wrap gracefulKill's initial SIGTERM in try/catch so an already-exited child doesn't skip shutdownServer - Broaden telemetry redaction regex to match mixed-case env var names
1 parent 5dc4afa commit 05a825f

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/commands/local/run.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ const KILL_GRACE_MS = 5000;
288288
async function gracefulKill(
289289
child: ReturnType<typeof Bun.spawn>
290290
): Promise<void> {
291-
child.kill("SIGTERM");
291+
try {
292+
child.kill("SIGTERM");
293+
} catch {
294+
return;
295+
}
292296
let graceTimer: ReturnType<typeof setTimeout> | undefined;
293297
const exited = await Promise.race([
294298
child.exited.then(() => true),

src/lib/dev-script.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ const WHITESPACE_RE = /\s+/;
1818

1919
/**
2020
* Matches script values that use shell features (env-var assignments,
21-
* operators, redirects) which cannot be tokenized by simple whitespace
22-
* splitting and must be run via `sh -c`.
21+
* variable expansion, operators, redirects) which cannot be tokenized
22+
* by simple whitespace splitting and must be run via `sh -c`.
2323
*/
24-
const SHELL_FEATURES_RE = /^[A-Z_]+=\S|&&|\|\||[|><;]/;
24+
const SHELL_FEATURES_RE = /^[A-Za-z_]+=\S|&&|\|\||[|><;$]/;
2525

2626
/**
2727
* Detect the project's dev command by inspecting filesystem markers in priority order.

src/lib/init/verify-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export async function verifySetup(
153153
features: result.result?.features,
154154
detectedCommand: detected.args
155155
.join(" ")
156-
.replace(/[A-Z_]+=\S+/g, (m) => `${m.split("=")[0]}=[REDACTED]`),
156+
.replace(/[A-Za-z_]\w*=\S+/g, (m) => `${m.split("=")[0]}=[REDACTED]`),
157157
detectedSource: detected.source,
158158
};
159159

0 commit comments

Comments
 (0)