2017-08-04 12:25:20 +08:00
|
|
|
|
|
|
|
####################
|
2017-10-10 14:34:50 +08:00
|
|
|
# Read with no vars is not an error
|
2017-08-04 12:25:20 +08:00
|
|
|
|
|
|
|
####################
|
|
|
|
# Read with -a and anything other than exactly on var name is an error
|
2017-08-10 02:11:58 +08:00
|
|
|
|
|
|
|
####################
|
|
|
|
# Verify correct behavior of subcommands and splitting of input.
|
2014-07-14 13:36:26 +08:00
|
|
|
2
|
|
|
|
2
|
|
|
|
1
|
2014-08-29 09:27:23 +08:00
|
|
|
[one
|
|
|
|
two]
|
|
|
|
1
|
|
|
|
[one
|
|
|
|
two]
|
|
|
|
1
|
|
|
|
[one
|
|
|
|
two
|
|
|
|
]
|
2014-07-14 13:36:26 +08:00
|
|
|
|
2017-08-04 12:25:20 +08:00
|
|
|
####################
|
2017-07-20 11:22:34 +08:00
|
|
|
# Test splitting input
|
2014-07-14 13:36:26 +08:00
|
|
|
1 'hello' 1 'there'
|
|
|
|
1 'hello there'
|
|
|
|
1 ''
|
|
|
|
1 '' 1 ''
|
|
|
|
1 'test' 1 '' 1 ''
|
2020-02-29 17:53:37 +08:00
|
|
|
1 'foo' 1 'bar' 1 ' baz'
|
2014-09-22 11:00:26 +08:00
|
|
|
0 a
|
2014-07-14 13:36:26 +08:00
|
|
|
|
2017-08-04 12:25:20 +08:00
|
|
|
####################
|
2017-07-20 11:22:34 +08:00
|
|
|
# Test splitting input with IFS empty
|
2014-07-14 13:36:26 +08:00
|
|
|
1 'hello'
|
|
|
|
1 'h' 1 'ello'
|
|
|
|
1 'h' 1 'e' 1 'llo'
|
2018-04-18 10:20:57 +08:00
|
|
|
0
|
|
|
|
1 't' 0
|
|
|
|
1 't' 0 0
|
2014-07-14 13:36:26 +08:00
|
|
|
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
|
2014-08-19 20:28:08 +08:00
|
|
|
|
2017-08-05 03:04:32 +08:00
|
|
|
####################
|
2014-08-19 20:28:08 +08:00
|
|
|
# read -n tests
|
|
|
|
tes
|
|
|
|
test
|
|
|
|
test
|
|
|
|
tes
|
|
|
|
tin
|
|
|
|
t
|
2014-09-22 10:18:56 +08:00
|
|
|
|
2017-08-05 03:04:32 +08:00
|
|
|
####################
|
2014-09-22 10:18:56 +08:00
|
|
|
# read -z tests
|
|
|
|
testing
|
|
|
|
test ing
|
|
|
|
newline
|
|
|
|
|
|
|
|
1 'test' 1 'ing'
|
|
|
|
1 'test' 1 ''
|
|
|
|
1 'foo' 1 'bar'
|
|
|
|
2 'foo' 'bar'
|
|
|
|
2 'baz' 'quux'
|
2017-01-22 04:43:20 +08:00
|
|
|
|
2017-08-04 12:25:20 +08:00
|
|
|
####################
|
|
|
|
# Chunked read tests
|
2017-01-22 04:43:20 +08:00
|
|
|
Chunked reads test pass
|
2017-08-04 12:25:20 +08:00
|
|
|
|
|
|
|
####################
|
|
|
|
# Confirm reading non-interactively works -- #4206 regression
|
|
|
|
$a: not set in local scope
|
|
|
|
$a: set in global scope, unexported, with 1 elements
|
2017-08-05 08:08:25 +08:00
|
|
|
$a[1]: length=3 value=|abc|
|
2017-08-04 12:25:20 +08:00
|
|
|
$a: not set in universal scope
|
|
|
|
|
|
|
|
$b: not set in local scope
|
|
|
|
$b: set in global scope, unexported, with 1 elements
|
2017-08-05 08:08:25 +08:00
|
|
|
$b[1]: length=3 value=|def|
|
2017-08-04 12:25:20 +08:00
|
|
|
$b: not set in universal scope
|
|
|
|
|
|
|
|
|
|
|
|
####################
|
|
|
|
# Test --delimiter (and $IFS, for now)
|
2017-07-27 21:06:01 +08:00
|
|
|
a=b
|
|
|
|
|
2017-08-04 12:25:20 +08:00
|
|
|
|
|
|
|
####################
|
|
|
|
# Delimiter =
|
2017-07-27 21:06:01 +08:00
|
|
|
a
|
|
|
|
b
|
2017-08-04 12:25:20 +08:00
|
|
|
|
|
|
|
####################
|
|
|
|
# Delimiter empty
|
2017-07-27 21:06:01 +08:00
|
|
|
a
|
|
|
|
=
|
|
|
|
b
|
2017-08-04 12:25:20 +08:00
|
|
|
|
|
|
|
####################
|
|
|
|
# IFS empty string
|
2017-07-27 21:06:01 +08:00
|
|
|
a
|
|
|
|
=
|
|
|
|
b
|
2017-08-04 12:25:20 +08:00
|
|
|
|
|
|
|
####################
|
|
|
|
# IFS unset
|
2017-07-27 21:06:01 +08:00
|
|
|
a=b
|
|
|
|
|
|
|
|
|
2017-08-04 12:25:20 +08:00
|
|
|
|
|
|
|
####################
|
|
|
|
# Delimiter =
|
2017-07-27 21:06:01 +08:00
|
|
|
a
|
|
|
|
b
|
|
|
|
|
|
|
|
|
|
|
|
Multi-char delimiters with -d
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
Multi-char delimiters with IFS
|
|
|
|
a
|
|
|
|
b
|
2020-02-29 17:53:37 +08:00
|
|
|
..c
|
2018-04-11 03:45:28 +08:00
|
|
|
|
|
|
|
banana sausage
|