Raise the recursion limit of complete

Users should generally prefer to use complete --wraps but this
corrects some unexpected behavior.

Fixes #3474
This commit is contained in:
Johannes Altmanninger 2019-10-03 07:58:04 +02:00 committed by Fabian Homborg
parent aa011f70a8
commit e167714899
3 changed files with 24 additions and 4 deletions

View file

@ -337,7 +337,7 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
cleanup_t remove_transient([&] { parser.libdata().transient_commandlines.pop_back(); });
// Allow a limited number of recursive calls to complete (#3474).
if (parser.libdata().builtin_complete_recursion_level >= 1) {
if (parser.libdata().builtin_complete_recursion_level >= 24) {
streams.err.append_format(L"%ls: maximum recursive depth reached\n", cmd);
} else {
parser.libdata().builtin_complete_recursion_level++;

View file

@ -64,4 +64,27 @@ complete
complete -c complete_test_recurse1 -xa '(echo recursing 1>&2; complete -C"complete_test_recurse1 ")'
complete -C'complete_test_recurse1 '
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: recursing
# CHECKERR: complete: maximum recursive depth reached

View file

@ -19,13 +19,10 @@ function testcommand2_complete
set -l tokens (commandline -opc) (commandline -ct)
set -e tokens[1]
echo $tokens 1>&2
complete -C"$tokens"
end
complete -c testcommand2 -x -a "(testcommand2_complete)"
complete -c testcommand2 --wraps "testcommand2 from_wraps "
complete -C'testcommand2 explicit '
# CHECKERR: explicit
# CHECKERR: complete: maximum recursive depth reached
# CHECKERR: from_wraps explicit
# CHECKERR: complete: maximum recursive depth reached