-
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[completion] Fix two sources of infinite loops.
- The basename() test in GetSpecForFirst() was broken, which caused an infinite loop when running ~/.local/bin/mypy. Fixed with unit test. - The 124 protocol now tests if the completion spec was changed before retrying. This prevents a function that simply does 'return 124' from entering an infinite loop. The unit tests have coverage for this case via 'return-124.bash'. Addresses issue #208.
- Loading branch information
Andy Chu
committed
Feb 3, 2019
1 parent
a698e3c
commit c9f431a
Showing
6 changed files
with
115 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
_bad() { | ||
#argv "$@" | ||
|
||
echo '_bad returning 124' | ||
|
||
# This caused an infinite loop in OSH, but not in bash. We have to test if | ||
# the return value is 124 AND the compspec was updated. | ||
# | ||
# In bash, it seems like you EITHER set COMPREPLY or return 124, not BOTH! | ||
# If it sees 124, it doesn't process the completions (unlike OSH at the | ||
# moment). | ||
|
||
#COMPREPLY=(x y) | ||
|
||
return 124 | ||
} | ||
complete -F _bad bad | ||
|
||
_both() { | ||
#echo '_both setting COMPREPLY and returning 124' | ||
COMPREPLY=(x y) | ||
return 124 | ||
} | ||
complete -F _both both | ||
|
||
_both2() { | ||
#echo '_both setting COMPREPLY and returning 124' | ||
COMPREPLY=(x y) | ||
complete -W 'b1 b2' both2 | ||
return 124 | ||
} | ||
complete -F _both2 both2 | ||
|
||
_default() { | ||
echo '_default returning 124 without changing completion spec' | ||
# We're supposed to source something here, but we didn't | ||
return 124 | ||
} | ||
|
||
complete -F _default -D |