Skip to content

[bug] Unquoted positional parameter in array assignment is not word-split on IFS: set -- a.b.c; IFS=.; A=($1) gives 1 element (GNU 3) — breaks OMB _omb_util_split / half-life git version compare #298

Closed

Description

@caomengxuan666

Found by the ecosweep lane (wt10/ecosweep, 2026-09-28) triaging the oh-my-bash 83-theme matrix (rubash e207b0d).

Minimal reproducer (script file, both shells)

set -- "2.55.0.windows.3"
IFS=.
A=($1)
echo "n=${#A[@]} [${A[1]}]"
  • GNU bash 5.3.0: n=5 [55] — the unquoted $1 word-splits on the custom IFS.
  • rubash: n=1 [] — no split at all.

Named variables split correctly under the same conditions (v=a.b.c; IFS=.; B=($v) → 3 both
shells), so the miss is specific to positional-parameter expansion in an assignment-RHS
array word. The same failure appears with a function-local local IFS=.; B=($2).

Real-world impact

  • oh-my-bash lib/utils.sh:409 _omb_util_split is exactly this shape
    (eval -- "$1=(\$2)" with local IFS=${3:-...}): every dotted split silently
    produces a single-element array under rubash.
  • lib/git.sh:185 git_compare_version then feeds ((INSTALLED_GIT_VERSION[i] > ...))
    the full string 2.55.0.windows.3 → four
    ((: 2.55.0.windows.3: arithmetic syntax error: invalid arithmetic operator diagnostics
    per prompt under the half-life theme (non-fatal; PS1 still built). GNU run of the same
    theme (LF OMB copy) is error-free.
  • Every other OMB consumer of _omb_util_split with a non-default delimiter is affected.

Isolation matrix (all script-file, GNU-verified)

shape rubash GNU
IFS=.; A=($1) n=1 n=5
local IFS=.; B=($2) (in fn) n=1 n=5
v=...; IFS=.; C=($v) n=5 n=5
local a=$- IFS=.; eval 'D=($v)' n=5 n=5
local IFS=.; eval -- 'E=($2)' n=1 n=5
local IFS=.; eval -- "$1=($v)" n=5 n=5

GNU C anchor

Assignment-RHS words go through subst.c:11229 expand_word_internal() in the assignment
context; positional parameters are expanded by subst.c expand_word_internal ->
parameter_expand exactly like named variables, and unquoted results are field-split with
the current IFS (subst.c split_fields() / field splitting after expansion). No C rule
exempts $1 from splitting in an assignment word.

Related earlier family members (different symptoms, same subsystem): #218 (assignment RHS
\ collapse), #212 (quoted alternate over-split), #194 (quoted join split), #198
(post-expansion subscript words).

Artifacts

  • target/issue-suites/results/ecosweep/probes/p15-posparam-split.sh — minimal
  • target/issue-suites/results/ecosweep/probes/p11-omb-split.sh .. p14-eval-indirect.sh — isolation ladder
  • target/issue-suites/results/ecosweep/omb/themes/half-life.err — the theme-level diagnostics

Activity

  1. added
    bug
    gnu-baseline
    on Sep 28, 2026
  2. caomengxuan666 commented on Sep 28, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt10/fieldsplit (85fa9264, master ef9b4ee): the compound-assignment fast paths (bare $N, $@ regardless of quoting, dynamic vars) stored expansion results as single elements without IFS splitting. GNU anchors: arrayfunc.c:557 expand_compound_array_assignment -> :610 expand_words_no_vars -> subst.c:12590 (only W_QUOTED/W_NOSPLIT words skip splitting; unquoted $@ joins with IFS[0] per subst.c:2957). Empty-expansion guard added at two field-split call sites (empty contributes zero fields, subst.c:13219).

    Verification: 15-form matrix (bare/${1}/mixed x$1y/quoted/singly-quoted/$@/${@}/"$@"/"${@}"/$*/[N]=$1/empty/unset/consecutive separators/$EPOCHREALTIME/$0) byte-identical to WSL GNU Bash 5.3.0; 12 new regression tests; 497 lib green.

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

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions