|
11 | 11 | * `scripts/generate-exports.js` uses — so the two cannot drift as files move. |
12 | 12 | * |
13 | 13 | * Why a Node runner rather than a shell pipeline: |
14 | | - * - `lex … $(node …)` swallows a producer failure (command substitution discards |
15 | | - * its exit code) and can hit ARG_MAX. |
| 14 | + * - `lex … $(node …)` swallows a producer failure: command substitution |
| 15 | + * discards the inner exit code, so lex runs on whatever (partial/empty) |
| 16 | + * output it produced and may report success. |
16 | 17 | * - `node … | xargs -0 lex …` needs `set -o pipefail` to propagate a producer |
17 | 18 | * failure, and `pipefail` is NOT portable across the `sh` npm runs scripts |
18 | 19 | * with (rejected by the dash on GitHub's Ubuntu runners). |
19 | | - * This runner is a single process with one authoritative exit code, passes the |
20 | | - * file list to `lex` as argv (no shell, no ARG_MAX), and forwards lex's exit |
21 | | - * code. No shell builtins involved. |
| 20 | + * This runner is a single process with one authoritative exit code: it forwards |
| 21 | + * lex's exit code (and fails on an empty list or a spawn error). Passing the |
| 22 | + * file list as argv also avoids shell word-splitting/quoting pitfalls. (It does |
| 23 | + * not lift the OS `execve` argument-length limit — argv is still bounded — but |
| 24 | + * that limit is ~2 MB on Linux, far above the few KB this list occupies.) |
22 | 25 | * |
23 | 26 | * Usage (in package.json): |
24 | 27 | * node ./scripts/run-lex-codegen.js gen-api --yes ./generated |
@@ -73,8 +76,10 @@ if (files.length === 0) { |
73 | 76 | } |
74 | 77 |
|
75 | 78 | // `shell: false` (the default) — args are passed as argv, so there is no shell |
76 | | -// word-splitting, no ARG_MAX limit from a command line, and lex's exit code is |
77 | | -// ours. stdio inherited so `> file` redirection in the npm script still works. |
| 79 | +// word-splitting/quoting to get wrong, and lex's exit code is ours. (argv is |
| 80 | +// still subject to the OS `execve` arg-length limit, but that is ~2 MB on Linux |
| 81 | +// vs. the few KB this list occupies.) stdio inherited so `> file` redirection in |
| 82 | +// the npm script still works. |
78 | 83 | const result = spawnSync("lex", [...lexArgs, ...files], { stdio: "inherit" }); |
79 | 84 | if (result.error) { |
80 | 85 | process.stderr.write( |
|
0 commit comments