Skip to content

fix(executor): expand the coproc name before validating it (Refs #3032) - #3709

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3032-coproc-name-expansion
Nov 15, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3032-coproc-name-expansion

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

  • rubash#3032: execute_coproc validated the parser's literal name token before expansion — coproc $nv { ...; } reported `$nv' and rejected valid expanded names
  • GNU execute_cmd.c:2502-2513 execute_coproc runs expand_string_unsplit_to_string on the explicit name, then validates the expansion; zero-field (unquoted unset/empty) expansion is NULL → err_invalidid (error.c:459-462) prints (null); quoted empty is one field → `'
  • Now: expand name_metadata.raw, treat unquoted zero-field expansion as NULL, validate the expansion, bind the fd array / _PID under the expanded name

Test plan

  • tests/issue3032_coproc_name_expansion.rs — 6/6 pins green
  • Dual-run probes vs WSL GNU Bash 5.3.20 byte-identical (unset/empty → (null), 9bad → 9bad, MYCP → named coproc, ''/"$nv" → `')
  • Coproc name-adjacent regressions green (issue1153 2/3 — 1 env-bound PATH failure identical on base; issue1652/2890/2746 — 1 pre-existing abs-path redir failure identical on base)

Generated with Devin

GNU execute_cmd.c:2502-2513 execute_coproc runs
expand_string_unsplit_to_string on the explicit name and validates the
EXPANSION, then binds the fd array and _PID var under the expanded text.
When the word expands to zero fields (unquoted unset/empty $nv) the
expansion is NULL and err_invalidid (error.c:459-462) renders `(null)`;
a quoted word still yields one field, so `coproc "$nv"` reports `':.

Rubash validated the parser's literal token, so `coproc $nv { ...; }`
reported `` `$nv': not a valid identifier `` and rejected valid
expanded names like MYCP. Use name_metadata.raw (the source spelling),
expand it, treat an unquoted zero-field expansion as NULL, validate the
expanded name, and register the coproc under it.

Pin: tests/issue3032_coproc_name_expansion.rs (6 shapes: unset/empty ->
(null), invalid expanded -> expanded value, valid expanded -> named
coproc with fd array + PID, literal invalid -> literal, quoted empty ->
`':).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant