mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 18:03:37 +08:00
c2cfc65cf2
`read` with IFS empty was expected to set all parameters after the first n filled variables to an empty string, but that was inconsistent with the behavior of `read` everywhere else. I'm not sure why fish differed from the spec with regards to the behavior in the event of an empty IFS: we eschew IFS where possible, yet here we adopt non-standard behavior splitting on every (unicode) character instead of not splitting at all with IFS empty. We still do that, but now the unset variables are treated as they normally would be, i.e. cleared and not set to an empty string (which is what an empty value between two IFS separators would contain).
135 lines
1.6 KiB
Plaintext
135 lines
1.6 KiB
Plaintext
|
|
####################
|
|
# Read with no vars is not an error
|
|
|
|
####################
|
|
# Read with -a and anything other than exactly on var name is an error
|
|
|
|
####################
|
|
# Verify correct behavior of subcommands and splitting of input.
|
|
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'
|
|
0
|
|
1 't' 0
|
|
1 't' 0 0
|
|
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: not set in local scope
|
|
$a: set in global scope, unexported, with 1 elements
|
|
$a[1]: length=3 value=|abc|
|
|
$a: not set in universal scope
|
|
|
|
$b: not set in local scope
|
|
$b: set in global scope, unexported, with 1 elements
|
|
$b[1]: length=3 value=|def|
|
|
$b: not set in universal scope
|
|
|
|
|
|
####################
|
|
# Test --delimiter (and $IFS, for now)
|
|
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
|
|
|
|
banana sausage
|