summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-03-29 16:06:20 +0430
committerAndreas Kling <kling@serenityos.org>2022-03-29 15:42:55 +0200
commite1cf51b0bd41a7c5854f8b741ee277492dfd6b6b (patch)
tree1689621d77dbd45369a19ac48c378d4bf30b719c /Userland
parentcdca6fc11386be8a35aa29d1b80ca17ef19bc906 (diff)
downloadserenity-e1cf51b0bd41a7c5854f8b741ee277492dfd6b6b.zip
Shell: Add a shell option for autocompleting via the program itself
This feature needs a bit more work, so let's disable it by default. Note that the shell will still use _complete_foo if it is defined regardless of this setting.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Shell/Shell.cpp2
-rw-r--r--Userland/Shell/Shell.h3
2 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp
index 7b430f8eef..29a0540cff 100644
--- a/Userland/Shell/Shell.cpp
+++ b/Userland/Shell/Shell.cpp
@@ -1668,6 +1668,8 @@ ErrorOr<Vector<Line::CompletionSuggestion>> Shell::complete_via_program_itself(s
auto completion_utility_name = String::formatted("_complete_{}", completion_command.argv[0]);
if (binary_search(cached_path, completion_utility_name))
completion_command.argv[0] = completion_utility_name;
+ else if (!options.invoke_program_for_autocomplete)
+ return Error::from_string_literal("Refusing to use the program itself as completion source");
completion_command.argv.extend({ "--complete", "--" });
diff --git a/Userland/Shell/Shell.h b/Userland/Shell/Shell.h
index 6c1ac34c2d..79bf8c327d 100644
--- a/Userland/Shell/Shell.h
+++ b/Userland/Shell/Shell.h
@@ -56,7 +56,8 @@
#define ENUMERATE_SHELL_OPTIONS() \
__ENUMERATE_SHELL_OPTION(inline_exec_keep_empty_segments, false, "Keep empty segments in inline execute $(...)") \
- __ENUMERATE_SHELL_OPTION(verbose, false, "Announce every command that is about to be executed")
+ __ENUMERATE_SHELL_OPTION(verbose, false, "Announce every command that is about to be executed") \
+ __ENUMERATE_SHELL_OPTION(invoke_program_for_autocomplete, false, "Attempt to use the program being completed itself for autocompletion via --complete")
#define ENUMERATE_SHELL_IMMEDIATE_FUNCTIONS() \
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(concat_lists) \