firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

fix: shell-args-parsing-bug

Open IzaakGough opened this issue 5 months ago • 0 comments

Summary

Resolves #6446

This fixes a standalone CLI shell-wrapper bug that left npm's -- sentinel in place when invoking shell -c -- <command>, which caused /bin/sh: --: invalid option during framework and function build steps. It normalizes shell arguments before dispatch and adds regression coverage for both argument parsing and Script_ShellJS execution.

Problem/Root Cause

The issue reports deploy and build failures from the standalone CLI path with commands shaped like .../runtime/shell -c -- <command>. The runtime wrapper stripped -c but did not also remove the sentinel that follows it, so the generated shell runtime could treat -- as the command to execute. That surfaces as /bin/sh: --: invalid option instead of running the intended npm or node command.

Solution/Changes

The shell argument cleanup is moved into a reusable normalizeShellScriptArgs helper in standalone/runtime.js. That helper removes -c and only strips the following -- when it is acting as npm's sentinel, while preserving other leading -- arguments and any arguments that follow the command string. The generated standalone shell.js now includes and uses the same helper, and the new regression tests cover both direct normalization behavior and the Script_ShellJS path that forks node commands after normalization.

Testing

  • Added regression tests in src/standalone/runtime.spec.ts covering normalizeShellScriptArgs and Script_ShellJS.

IzaakGough avatar Jun 12 '26 14:06 IzaakGough