Files
sausage/userland/brush/source/brush-shell/tests/cases/compat/completion.yaml
T
2026-11-11 22:04:16 +00:00

68 lines
2.3 KiB
YAML

name: "Interactive completion"
incompatible_configs: ["sh"]
cases:
# A completion function that returns 124 restarts completion, which uses the specs as
# the function left them, including the special ones (e.g. a `-D` loader replacing
# itself).
- name: "Restarted completion uses the specs the completion function registered"
min_oracle_version: 5.3 # bash 5.2 doesn't restart with a replaced -D spec
pty: true
ignore_stdout: true
stdin: |
#expect-prompt
_load() { complete -D -W loaded; return 124; }; complete -D -F _load; zz() { printf '<%s>\n' "$@"; }
#send:Enter
#expect-prompt
zz l
#send:Tab
#send:Enter
#expect:<loaded>
#expect-prompt
#send:Ctrl+D
# Like bash, a completion function that asks for a restart doesn't leave its `COMPREPLY`
# behind, even when the restart uses a spec that isn't a function.
- name: "Restarted completion discards the COMPREPLY the function set"
pty: true
ignore_stdout: true
stdin: |
#expect-prompt
_f() { COMPREPLY=(leak); complete -W word zz; return 124; }; complete -F _f zz; zz() { :; }
#send:Enter
#expect-prompt
zz w
#send:Tab
#send:Enter
#expect-prompt
[[ -v COMPREPLY ]] && echo "<leak""ed>" || echo "<un""set>"
#send:Enter
#expect:<unset>
#expect-prompt
#send:Ctrl+D
# `compopt` with no names or options shows the options of the completion in progress,
# as `compopt` in the completion function left them, named by the spec in use: the one
# found by the command's file name, or the default spec.
- name: "compopt with no options in a completion function prints the completion's options"
min_oracle_version: "5.3" # the fullquote option was added in 5.3
pty: true
ignore_stdout: true
stdin: |
#expect-prompt
_f() { { compopt; compopt -o nospace +o filenames; compopt; compopt zz; } >>out 2>&1; COMPREPLY=(xy); }; complete -o filenames -F _f zz; complete -D -F _f; zz() { :; }; yy() { :; }
#send:Enter
#expect-prompt
zz x
#send:Tab
#send:Enter
#expect-prompt
yy x
#send:Tab
#send:Enter
#expect-prompt
./zz x
#send:Tab
#send:Enter
#expect-prompt
#send:Ctrl+D