From 58b696bed16d2b5c859f218e00fd82570be60ead Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 17 Jan 2019 09:49:50 +0100 Subject: [PATCH] complete: Don't allow wrapping a command with itself Double-fixes #5541, by not allowing it to happen. --- src/complete.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/complete.cpp b/src/complete.cpp index effcb05e9..5ef7d3dfd 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -1656,6 +1656,11 @@ bool complete_add_wrapper(const wcstring &command, const wcstring &new_target) { return false; } + // If the command and the target are the same, + // there's no point in following the wrap-chain because we'd only complete the same thing. + // TODO: This should maybe include full cycle detection. + if (command == new_target) return false; + auto locked_map = wrapper_map.acquire(); wrapper_map_t &wraps = *locked_map; wcstring_list_t *targets = &wraps[command];