From cb6ac380048228915624f1eb4266950784a0724e Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Fri, 20 Jul 2018 16:48:05 +0900 Subject: [PATCH] special case sudo and gsudo in sh tab completion --- apps/sh.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/sh.c b/apps/sh.c index c06228a9..e90d2783 100644 --- a/apps/sh.c +++ b/apps/sh.c @@ -222,7 +222,18 @@ void tab_complete_func(rline_context_t * c) { char * match = NULL; int free_matches = 0; int no_space_if_only = 0; + + int complete_mode = 1; + if (cursor == 0 && !strchr(prefix,'/')) { + complete_mode = 0; + } + + if (cursor == 1 && !strchr(prefix,'/') && (!strcmp(argv[0],"sudo") || !strcmp(argv[0], "gsudo"))) { + complete_mode = 0; + } + + if (complete_mode == 0) { /* Complete binary name */ for (int i = 0; i < shell_commands_len; ++i) { if (strstr(shell_commands[i], prefix) == shell_commands[i]) {