]>
Commit | Line | Data |
---|---|---|
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 | |
17 | bind 'set enable-bracketed-paste off' 2>/dev/null | |
18 | ||
19 | read -t 0.00001 -e var | |
20 | estat=$? | |
21 | if [ $estat -gt 128 ]; then | |
22 | echo timeout 1: ok | |
23 | else | |
24 | echo $estat | |
25 | fi | |
26 | echo ${var:-unset or null 1} | |
27 | ||
28 | read -e -t 0.1 var | |
29 | estat=$? | |
30 | if [ $estat -gt 128 ]; then | |
31 | echo timeout 2: ok | |
32 | else | |
33 | echo $estat | |
34 | fi | |
35 | echo ${var:-unset or null 2} | |
36 | ||
37 | read -e -t 1 var < /dev/tty | |
38 | estat=$? | |
39 | if [ $estat -gt 128 ]; then | |
40 | echo timeout 3: ok | |
41 | else | |
42 | echo $estat | |
43 | fi | |
44 | echo ${var:-unset or null 3} | |
45 | ||
46 | sleep 1 | read -t 0.25 -e a | |
47 | estat=$? | |
48 | if [ $estat -gt 128 ]; then | |
49 | echo timeout 4: ok | |
50 | else | |
51 | echo $estat | |
52 | fi | |
53 | ||
54 | # the above should all time out | |
55 | echo abcde | { | |
56 | read -e -t 0.5 a | |
57 | echo $a | |
58 | } | |
59 | ||
60 | read -e -t .0001 a <<<abcde | |
61 | echo $a | |
187661b8 CR |
62 | |
63 | set -o posix | |
64 | read -t 0.1 a </dev/tty | |
65 | echo $a | |
66 |