]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/read7.sub
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / read7.sub
CommitLineData
4491c030
CR
1# This program is free software: you can redistribute it and/or modify
2# it under the terms of the GNU General Public License as published by
3# the Free Software Foundation, either version 3 of the License, or
4# (at your option) any later version.
5#
6# This program is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9# GNU General Public License for more details.
10#
11# You should have received a copy of the GNU General Public License
12# along with this program. If not, see <http://www.gnu.org/licenses/>.
13#
14# test behavior of native readline timeouts
15
16# turn off bracketed paste to avoid spurious output
17bind 'set enable-bracketed-paste off' 2>/dev/null
18
19read -t 0.00001 -e var
20estat=$?
21if [ $estat -gt 128 ]; then
22 echo timeout 1: ok
23else
24 echo $estat
25fi
26echo ${var:-unset or null 1}
27
28read -e -t 0.1 var
29estat=$?
30if [ $estat -gt 128 ]; then
31 echo timeout 2: ok
32else
33 echo $estat
34fi
35echo ${var:-unset or null 2}
36
37read -e -t 1 var < /dev/tty
38estat=$?
39if [ $estat -gt 128 ]; then
40 echo timeout 3: ok
41else
42 echo $estat
43fi
44echo ${var:-unset or null 3}
45
46sleep 1 | read -t 0.25 -e a
47estat=$?
48if [ $estat -gt 128 ]; then
49 echo timeout 4: ok
50else
51 echo $estat
52fi
53
54# the above should all time out
55echo abcde | {
56 read -e -t 0.5 a
57 echo $a
58}
59
60read -e -t .0001 a <<<abcde
61echo $a
187661b8
CR
62
63set -o posix
64read -t 0.1 a </dev/tty
65echo $a
66