Skip to content

bug: preserve exact string and list semantics under nocasematch #531

Description

@codeforester

Goal

preserve exact string and list semantics under nocasematch.

Background and evidence

Release-preparation review of a90aa1429647b6eb4820a01aabe37799ca55ad5e on macOS arm64. Bash 5.3.20; ordinary local POSIX filesystem.

With caller-owned shopt -s nocasematch, base_str_split can loop indefinitely and list operations stop matching exactly. This is distinct from closed #524, which corrected array-kind validation under the same option.

From the repository root, run the split case in a subprocess with a short timeout:

source lib/bash/std/lib_std.sh
base_std_import str/lib_str.sh list/lib_list.sh
shopt -s nocasematch
declare -a result=()
base_str_split result 'aB' 'b'   # hangs

The loop's [[ value == *separator* ]] is case-insensitive, but parameter removal is case-sensitive. The remainder stays aB forever while the result array grows. Expected: one unsplit aB field.

Independent exact-match probe:

declare -a words=(A a)
base_list_remove words a
declare -p words

Actual: empty array. Expected: (A). base_list_contains and string predicates use the same option-sensitive comparison pattern.

The sourceable-library contract preserves caller shell state; it should not require consumers to disable an existing option to avoid a hang or extra deletions.

Scope and acceptance criteria

  • Make documented exact string/list operations independent of nocasematch while preserving the caller's option state.
  • Guarantee progress in base_str_split for all accepted separators.
  • Add bounded-time subprocess coverage for the differing-case split and exact-match list/string cases with the option both enabled and disabled.
  • Check affected declaration/parser comparisons for the same class of drift without silently changing supported case rules.

Validation

Run focused str/list BATS, the Bash option contract, and ./tests/validate.sh; retain Bash 4.2 compatibility.

Source references:

Non-goals

No release publication or unrelated API redesign. Preserve documented compatibility except for the defective behavior identified above.

Project fields

  • Project: base-bash-libs
  • Status: Ready
  • Priority: P1
  • Area: Shell
  • Initiative: Adoption Polish
  • Size: M
  • Milestone: v2.2.0

Agent assignment

Assignee: @codeforester. Implementation may be handled through the normal issue-backed worktree and reviewed PR workflow.

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions