Skip to content

shell: reflection_metaprogramming matches plain ${var} expansion (indirection marker is optional) and every $(...) -- 1,019 hits in 2,823 LOC on configure-helper.sh #2722

Description

@squid-protocol

Found while attributing #2719's golden-master diff: with per-file dynamism (reflection_metaprogramming) feeding documentation risk, 15 of the crucible's 46 shell files jump ≥ 25 points, to ~99% -- configure-helper.sh reads 1,019 reflection hits in 2,823 coding lines, ansible-galaxy__runme.sh 149 in 333, xcrun_cache.sh 122 in 225.

The shell rule (gitgalaxy/standards/language_standards/languages/shell.py):

\$\((?:[^()]|\([^()]*\))+\)|`[^`]+`|\b(?:awk|sed|perl|python[23]?|ruby)\s+['"][^'"]{0,500}|\beval\s+\$|\$\{!?[a-zA-Z0-9_]+\}

Two of its alternatives count ordinary shell as metaprogramming:

  1. \$\{!?[a-zA-Z0-9_]+\} -- the !? makes the indirection marker optional, so plain ${var} matches. ${!var} (indirect expansion) is reflection; ${var} is a variable. This looks like a typo for \$\{![a-zA-Z0-9_]+\}.
  2. \$\((?:...)\) and backticks -- every command substitution. test_shell_strict.py L105 pins output=$(date) as a positive, so this one is a deliberate decision by the rule's author; whether "runs a command" is the same thing as "dynamic dispatch a reader can't follow" is the question. On real shell it is one hit per ~3 lines, which is the language's vocabulary, not its dynamism -- the same shape as the control_flow_ratio vocabulary leak in length leaks: func_internal_density, avg_func_loc and control_flow_ratio read file length with content and tier held equal (rosetta F.1 design pass) #2705.

Suggested fix: (1) is a one-character change (!?!) and should be uncontroversial; for (2), keep eval, ${!var}, declare -n, source/. of a computed path, and the inline awk|sed|perl|python programs, and drop bare $(...)/backticks -- or move them to a signal that means "runs a command". reflection_metaprogramming is unplanted in keyword-rosetta, so the change is not gate-visible there; it is golden-master-visible (documentation and cognitive load on shell).

Related: #2716 (three-input model), #2719 (per-file dynamism), #2705 (vocabulary leaks).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnintended behavior or logic failure in the enginecore-engineModifications to the central physics and parsing enginemetricsHeuristics, risk exposures, and topological math updates

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions