mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 22:03:12 +00:00
b1866b18dc
This takes a string that is then split upon like `string split`. Unlike $IFS, the string is used as one piece, not a set of characters. There is still a fallback to IFS if no delimiter is given, that behaves exactly as before. Fixes #4156.
97 lines
904 B
Text
97 lines
904 B
Text
2
|
|
2
|
|
1
|
|
[one
|
|
two]
|
|
1
|
|
[one
|
|
two]
|
|
1
|
|
[one
|
|
two
|
|
]
|
|
|
|
# Test splitting input
|
|
1 'hello' 1 'there'
|
|
1 'hello there'
|
|
1 ''
|
|
1 '' 1 ''
|
|
1 'test' 1 '' 1 ''
|
|
1 'foo' 1 'bar' 1 ' baz'
|
|
0 a
|
|
|
|
# Test splitting input with IFS empty
|
|
1 'hello'
|
|
1 'h' 1 'ello'
|
|
1 'h' 1 'e' 1 'llo'
|
|
1 ''
|
|
1 't' 1 ''
|
|
1 't' 1 '' 1 ''
|
|
1 ' ' 1 't'
|
|
|
|
2 'hello' 'there'
|
|
1 'hello'
|
|
6 'this' 'is' 'a' 'bunch' 'of' 'words'
|
|
3 'one' 'two' 'three'
|
|
0
|
|
|
|
5 'h' 'e' 'l' 'l' 'o'
|
|
1 'h'
|
|
0
|
|
|
|
# read -n tests
|
|
tes
|
|
test
|
|
test
|
|
tes
|
|
tin
|
|
t
|
|
|
|
# read -z tests
|
|
testing
|
|
test ing
|
|
newline
|
|
|
|
1 'test' 1 'ing'
|
|
1 'test' 1 ''
|
|
1 'foo' 1 'bar'
|
|
2 'foo' 'bar'
|
|
2 'baz' 'quux'
|
|
|
|
# chunked read tests
|
|
Chunked reads test pass
|
|
# Confirm reading non-interactively works (#4206 regression)
|
|
$a count=1
|
|
$a[1]=|abc|
|
|
$b count=1
|
|
$b[1]=|def|
|
|
a=b
|
|
|
|
Delimiter =
|
|
a
|
|
b
|
|
Delimiter empty
|
|
a
|
|
=
|
|
b
|
|
IFS empty string
|
|
a
|
|
=
|
|
b
|
|
IFS unset
|
|
a=b
|
|
|
|
|
|
Delimiter =
|
|
a
|
|
b
|
|
|
|
|
|
Multi-char delimiters with -d
|
|
a
|
|
b
|
|
c
|
|
Multi-char delimiters with IFS
|
|
a
|
|
b
|
|
..c
|