OILS / spec / builtin-bind.test.sh View on Github | oils.pub

158 lines, 72 significant
1## oils_failures_allowed: 0
2## oils_cpp_failures_allowed: 7
3## compare_shells: bash
4
5# NB: This is only for NON-interactive tests of bind.
6# See spec/stateful/bind.py for the remaining tests.
7
8#### bind -l should report readline functions
9
10# This test depends on the exact version
11# bind -l | sort > _tmp/this-shell-bind-l.txt
12# comm -23 $REPO_ROOT/spec/testdata/bind/bind_l_function_list.txt _tmp/this-shell-bind-l.txt
13
14# More relaxed test
15bind -l | grep accept-line
16
17## status: 0
18## STDOUT:
19accept-line
20## END
21
22
23#### bind -p -P to print function names and key bindings
24
25# silly workaround for spec test format - change # comment to %
26bind -p | grep vi-subst | sed 's/^#/%/'
27echo
28
29bind -P | grep vi-subst
30
31## STDOUT:
32% vi-subst (not bound)
33
34vi-subst is not bound to any keys
35## END
36
37#### bind -s -S accepted
38
39# TODO: add non-trivial tests here
40
41bind -s
42bind -S
43
44## STDOUT:
45## END
46
47#### bind -v -V accepted
48
49bind -v | grep blink-matching-paren
50echo
51
52# transform silly quote so we don't mess up syntax highlighting
53bind -V | grep blink-matching-paren | sed "s/\`/'/g"
54
55## STDOUT:
56set blink-matching-paren off
57
58blink-matching-paren is set to 'off'
59## END
60
61#### bind -q
62
63bind -q zz-bad
64echo status=$?
65
66# bash prints message to stdout
67
68bind -q vi-subst
69echo status=$?
70
71bind -q yank
72echo status=$?
73
74## STDOUT:
75status=1
76vi-subst is not bound to any keys.
77status=1
78yank can be invoked via "\C-y".
79status=0
80## END
81
82
83#### bind -X
84bind -X | grep -oF '\C-o\C-s\C-h'
85echo status=$?
86
87bind -x '"\C-o\C-s\C-h": echo foo'
88bind -X | grep -oF '\C-o\C-s\C-h'
89bind -X | grep -oF 'echo foo'
90echo status=$?
91
92## STDOUT:
93status=1
94\C-o\C-s\C-h
95echo foo
96status=0
97## END
98
99
100#### bind -m with bind -x/-X
101bind -X | grep -oF 'emacs|vi'
102echo status=$?
103
104bind -m emacs -x '"\C-o\C-s\C-h": echo emacs'
105bind -m emacs -X | grep -oF 'emacs'
106echo status=$?
107
108bind -m vi -x '"\C-o\C-s\C-h": echo vi'
109bind -m vi -X | grep -oF 'vi'
110echo status=$?
111
112## STDOUT:
113status=1
114emacs
115status=0
116vi
117status=0
118## END
119
120
121#### bind -r
122bind -q yank | grep -oF '\C-o\C-s\C-h'
123echo status=$?
124
125bind '"\C-o\C-s\C-h": yank'
126bind -q yank | grep -oF '\C-o\C-s\C-h'
127echo status=$?
128
129bind -r "\C-o\C-s\C-h"
130bind -q yank | grep -oF '\C-o\C-s\C-h'
131echo status=$?
132
133## STDOUT:
134status=1
135\C-o\C-s\C-h
136status=0
137status=1
138## END
139
140
141#### bind -r of bind -x commands
142bind -X | grep -oF '\C-o\C-s\C-h'
143echo status=$?
144
145bind -x '"\C-o\C-s\C-h": echo foo'
146bind -X | grep -oF '\C-o\C-s\C-h'
147echo status=$?
148
149bind -r "\C-o\C-s\C-h"
150bind -X | grep -oF '\C-o\C-s\C-h'
151echo status=$?
152
153## STDOUT:
154status=1
155\C-o\C-s\C-h
156status=0
157status=1
158## END