Skip to content

shell: a control-flow keyword as a plain argument word desyncs Mode-D scope tracking #2459

Closed

Description

@squid-protocol

Summary

_slice_by_keywords (Mode D, shell) counts for / if / while / until / case as scope
openers wherever the word appears, not only at command position. An unquoted occurrence in a
command argument — e.g. an echo message — is counted as an opener with no matching closer,
desyncing the depth stack for the rest of the enclosing function.

Repro

language-crucible/data/shell/freebsd-src/runulp.sh:

t() {
    ...
    [ -n "$L" ] || { echo ERROR: Could not determine ULP limit for $routine in $limits_file && false; }
    ...
}

The bare word for in ... ULP limit for $routine ... (not a quoted string, so
_apply_literal_shield can't blank it) is counted as a \bfor\b opener. t's scope never
closes at its real }, and GitGalaxy emits t_[Truncated] instead of t — a recall miss for
t and an over-long satellite.

function_data for runulp.sh:

  1   __global_context__
  22  t_[Truncated]     <- should be `t`, real span 22..56
  100 check

Surfaced by the tri-comparison recall audit (tests/tools/recall_audit.py shell).

Fix direction

Only treat for/if/while/until/case/select as an opener when it is in command
position
— the first token of a statement (start of line, or after ;/&&/||/|/(/then/
do/else/backtick). Same command-position awareness the Ruby/Elixir inline-modifier guards and
#2405's shell brace guard already apply for their languages.

Found by

tri-comparison-ledger-sweep step 2.6 recall audit, 2026-08-29.

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

    bugcore-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions