2014-09-08 02:11:34 +00:00
|
|
|
# vim: set filetype=expect:
|
|
|
|
|
|
|
|
proc expect_read_prompt {} {
|
|
|
|
expect -re "\\r\\n?read> $"
|
|
|
|
}
|
|
|
|
|
|
|
|
proc expect_marker {text} {
|
|
|
|
expect_prompt -re "\\r\\n@MARKER:$text@\\r\\n" {} unmatched {
|
|
|
|
abort "Couldn't find marker line '$text'"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
spawn $fish
|
|
|
|
|
|
|
|
expect_prompt
|
|
|
|
|
|
|
|
# read
|
|
|
|
|
2017-10-10 06:34:50 +00:00
|
|
|
send_line "read"
|
|
|
|
expect_read_prompt
|
|
|
|
send_line "text"
|
|
|
|
expect_prompt
|
|
|
|
|
2014-09-08 02:11:34 +00:00
|
|
|
send_line "read foo"
|
|
|
|
expect_read_prompt
|
|
|
|
send_line "text"
|
|
|
|
expect_prompt
|
|
|
|
print_var_contents foo
|
|
|
|
|
|
|
|
send_line "read foo"
|
|
|
|
expect_read_prompt
|
|
|
|
send_line "again\r_marker 1"
|
|
|
|
expect_prompt
|
|
|
|
expect_marker 1
|
|
|
|
print_var_contents foo
|
|
|
|
|
|
|
|
send_line "read foo"
|
|
|
|
expect_read_prompt
|
|
|
|
send_line -h "bar\r_marker 2"
|
|
|
|
expect_prompt
|
|
|
|
expect_marker 2
|
|
|
|
print_var_contents foo
|
|
|
|
|
2017-04-09 18:48:21 +00:00
|
|
|
# read -i
|
|
|
|
|
|
|
|
send_line "read -i foo"
|
|
|
|
expect_read_prompt
|
|
|
|
send_line -h "read_i\r_marker 3"
|
|
|
|
expect_prompt
|
|
|
|
expect_marker 3
|
|
|
|
print_var_contents foo
|
|
|
|
|
2014-09-08 02:11:34 +00:00
|
|
|
# read -n
|
|
|
|
|
|
|
|
send_line "read -n 3 foo"
|
|
|
|
expect_read_prompt
|
|
|
|
send_line -h "123_marker 3"
|
|
|
|
expect_prompt
|
|
|
|
expect_marker 3
|
|
|
|
print_var_contents foo
|
|
|
|
|
|
|
|
send_line "read -n 3 foo"
|
|
|
|
expect_read_prompt
|
|
|
|
send_line "456_marker 4"
|
|
|
|
expect_prompt
|
|
|
|
expect_marker 4
|
|
|
|
print_var_contents foo
|
|
|
|
|
|
|
|
send_line "read -n 12 foo bar"
|
|
|
|
expect_read_prompt
|
|
|
|
send_line "hello world!_marker 5"
|
|
|
|
expect_prompt
|
|
|
|
expect_marker 5
|
|
|
|
print_var_contents foo
|
|
|
|
print_var_contents bar
|
|
|
|
|
|
|
|
send_line "bind ` 'commandline -i test'`"
|
|
|
|
expect_prompt
|
|
|
|
send_line "read -n 4 foo"
|
|
|
|
expect_read_prompt
|
|
|
|
send_line "te`_marker 6"
|
|
|
|
expect_prompt
|
|
|
|
expect_marker 6
|
|
|
|
print_var_contents foo
|
|
|
|
|
|
|
|
send_line "read -n 4 foo"
|
|
|
|
expect_read_prompt
|
|
|
|
send_line -h "12`_marker 7"
|
|
|
|
expect_prompt
|
|
|
|
expect_marker 7
|
|
|
|
print_var_contents foo
|
2017-01-02 02:07:42 +00:00
|
|
|
|
|
|
|
# ==========
|
|
|
|
# The fix for issue #2007 initially introduced a problem when using a function
|
|
|
|
# to read from /dev/stdin when that is associated with the tty. These tests
|
|
|
|
# are to ensure we don't introduce a regression.
|
|
|
|
send "r2l\n"
|
|
|
|
expect_read_prompt
|
|
|
|
send "abc\n"
|
|
|
|
expect_read_prompt
|
|
|
|
send "def\n"
|
|
|
|
expect "abc then def\r\n"
|
|
|
|
expect_prompt
|
|
|
|
|
|
|
|
send "r2l </dev/stdin\n"
|
|
|
|
expect_read_prompt
|
|
|
|
send "ghi\n"
|
|
|
|
expect_read_prompt
|
|
|
|
send "jkl\n"
|
|
|
|
expect "ghi then jkl\r\n"
|
|
|
|
expect_prompt
|