blob: e46d612f0e01c9151967c506fa4fcec5e07b64fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# Interactive: completion with Tab.
command -v python3 >/dev/null 2>&1 || exit 77
mkdir -p sub/deeper bin && touch onefile sub/inner.txt 'with space' aa1 aa2
printf '#!/bin/sh\necho ran-mytool\n' >bin/zz-mytool && chmod +x bin/zz-mytool
PS1='$ ' ENV='' HISTFILE='' ZTVAR_LONGNAME=val PATH=$PWD/bin:$PATH \
python3 "$TESTS/tools/ptydrive.py" "$TSH" <<'END'
# a unique file name, then a space
send ls on\t\r
expect onefile
# a directory gets "/" and the next Tab continues inside it
send cat su\tin\t\r
# a name that needs quoting
send ls wi\t\r
expect with space
# several candidates: complete the common part, then list
send echo a\t\t
expect aa2
send 1\r
expect aa1
# command position: PATH, builtins, functions, aliases
send zz-my\t\r
expect ran-mytool
send myfunc_long() { echo in-func; }\r
send myfunc_\t\r
expect in-func
send alias myalias_x='echo in-alias'\r
send myalias\t\r
expect in-alias
send unal\tmyalias_x\r
# variables
send echo $ZTVAR_L\t\r
expect val
# after a pipe is command position again; inside quotes no escaping, and
# a lone candidate closes the quote
send echo x | zz-my\t\r
expect ran-mytool
send ls "wi\t\r
expect with space
# nothing matches: bell, line unchanged
send echo nomatch\t\r
expect nomatch
send exit\r
END
|