Consolidate complete cycle detection and always report error on cycle

Detect recursive calls to builtin complete and the internal completion in
the same place.

In 0a0149cc2 (Prevent infinite recursion when completion wraps variable assignment)
we don't print an error when completing certain aliases like:

	alias vim "A=B vim"

But we also gave no completions.
We could make this case work, but I think that trying to salvage situations
like this one is way too complex. Instead, let the user know by printing an
error. Not sure if the style of the error fits.

We could add some heuristic to alias to not add --wraps in some cyclic cases.
This commit is contained in:
Johannes Altmanninger
2020-09-26 14:13:56 +02:00
parent 3dd9531472
commit 45e7c709f4
5 changed files with 25 additions and 20 deletions

View File

@@ -1,6 +1,8 @@
#RUN: %fish %s
# Validate some things about command wrapping.
set -g LANG C # For predictable error messages.
# This tests that we do not trigger a combinatorial explosion - see #5638.
# Ensure it completes successfully.
complete -c testcommand --wraps "testcommand x "
@@ -30,3 +32,4 @@ complete -C'testcommand2 explicit '
complete -c recvar --wraps 'A=B recvar'
complete -C 'recvar '
# CHECKERR: <E> fish: completion reached maximum recursion depth, possible cycle?