Skip to content

IFS-based word splitting not implemented #352

@chaliy

Description

@chaliy

Description

IFS-based word splitting is largely unimplemented. This affects 36 skipped tests in word-split.test.sh.

Scope

The following features are missing or broken:

  • IFS splitting: IFS=:; set -- $var does not split on custom IFS characters
  • $@/$* splitting/joining: Unquoted $@ and $* don't split arguments correctly in word context
  • Word elision: Empty unquoted variables should be elided (produce no words), but aren't
  • Non-whitespace IFS: Non-whitespace IFS characters should produce empty fields between adjacent delimiters
  • Mixed whitespace/non-whitespace IFS: Whitespace IFS chars are treated as delimiters with leading/trailing trimming, non-whitespace are not
  • set -- with word splitting: set -- $var doesn't produce correct argument count
  • Empty IFS: IFS='' should prevent all splitting
  • Unset IFS: unset IFS should behave like default $' \t\n'

Repro

# Expected: 3 args (a, b, c)
IFS=:
var="a:b:c"
set -- $var
echo $#    # bashkit outputs: 1 (wrong, should be 3)

# Expected: empty string elided, 2 args
empty=""
set -- 1 $empty 2
echo $#    # bashkit outputs: 3 (wrong, should be 2)

# Expected: "$*" joins with first char of IFS
IFS=:
set -- x 'y z'
echo "$*"  # bashkit outputs: x y z (wrong, should be x:y z)

Test coverage

36 skipped tests in crates/bashkit/tests/spec_cases/bash/word-split.test.sh (PR #351).

Oils reference: https://github.com/oilshell/oil/blob/master/spec/word-split.test.sh

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions