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