Skip to content

fix(executor): by-name BASH_ARGV0 reads materialize the listing cell (Refs #3026) - #3708

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3026-argv0-materialized-listing
Nov 15, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3026-argv0-materialized-listing

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

  • GNU BASH_ARGV0 is an ordinary INIT_DYNAMIC_VAR (variables.c:1850) — never att_invisible — and is absent from print_var_list only while its value cell is NULL (print_assignment early return, variables.c:1097-1100). Every find_variable read fires get_bash_argv0 → set_string_value (variables.c:1520-1524), binding dollar_vars[0] into the cell, so a named read (declare -p BASH_ARGV0, $BASH_ARGV0, typeset/export/readonly operands) makes later typeset/set/declare listings show BASH_ARGV0=<v>.
  • rubash kept BASH_ARGV0 INVISIBLE as the unset-cell stand-in but never recorded the getter's store, so declare -p BASH_ARGV0 printed the value yet the cell3 typeset listing stayed empty.
  • dynamic_parameter_value now records the store in dynamic_cells.values like the other getter-backed scalars; dynamic_set_views (assignment form) and dynamic_cell_view (declaration form) render the recorded cell. New DynamicSetView.scalar flag keeps scalar storage out of array_to_assign. unset BASH_ARGV0 drops the stored cell + the INVISIBLE stand-in (unbind_variable, variables.c:3839), so a later rebind is an ordinary visible variable — matching GNU.

GNU-faithful edges verified (WSL bash 5.3.20, script-file probes)

  • BASH_ARGV0=zzz alone does NOT list (assign_bash_argv0 swallows the bind; cell stays unset)
  • echo $BASH_ARGV0, declare -p, typeset/export/readonly name operands materialize → listed
  • stale-cell quirk: BASH_ARGV0=zzz; echo $BASH_ARGV0>/dev/null; BASH_ARGV0=yyy; typeset lists zzz
  • unset BASH_ARGV0; declare -p → not found; unset; BASH_ARGV0=zzz → relisted as plain var
  • subshell materialization stays isolated from the parent

Test plan

  • cargo test --test issue3026_typeset_listing_argv0_groups — 3/3
  • Dynamic-listing neighbours: issue2700, issue2770 (x2), issue2973, issue1364, issue1569 — green; issue1363's 2 failures are pre-existing Windows env_clear PATH-bound (grep unresolved, identical on the e81a1af base binary)
  • cargo test --lib — 1355/1356 (issue2084 env-bound: passes with WINUXSH_ROOT/BASH_ENV unset; passes on CI)
  • WSL dual-run chain + adjacent matrix byte-identical to GNU

Generated with Devin

…(Refs #3026)

GNU's BASH_ARGV0 is an ordinary INIT_DYNAMIC_VAR (variables.c:1850) —
never att_invisible — and is absent from print_var_list only while its
value cell is NULL (print_assignment's early return, variables.c
:1097-1100). Every find_variable read fires get_bash_argv0, whose
set_string_value (variables.c:1520-1524) binds dollar_vars[0] into the
cell, so `declare -p BASH_ARGV0` (declare.def:806 -> find_variable)
makes later `typeset`/`set`/`declare` listings show `BASH_ARGV0=<v>` —
and the stored snapshot even survives a later `BASH_ARGV0=` rebind,
whose assign_bash_argv0 writes dollar_vars[0] without touching the
cell.

Rubash marked BASH_ARGV0 INVISIBLE to stand in for the unset cell, but
nothing ever recorded the getter's store, so the listing stayed empty
after the named read. dynamic_parameter_value now records the store in
dynamic_cells.values like the other getter-backed scalars; the
assignment-form listing supply (dynamic_set_views) and the declaration
cell view both render that recorded cell, with a `scalar` flag on
DynamicSetView so the scalar storage isn't rendered through
array_to_assign. unbind_variable destroys the cell (variables.c:3839),
so `unset BASH_ARGV0` drops the stored value and the INVISIBLE
stand-in — a later rebind is an ordinary visible variable, matching
GNU.

WSL GNU bash 5.3.20 script-file verified: the materialization chain,
`BASH_ARGV0=` non-materializing assign, unset+declare not-found,
readonly/export/typeset operand materialization, unset+rebind relist,
subshell isolation, and the stale-snapshot-after-rebind quirk all match
byte-for-byte. Pin: tests/issue3026_typeset_listing_argv0_groups 3/3.

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