1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:47:34 +00:00

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.
This commit is contained in:
Ali Mohammad Pur 2022-03-29 16:06:20 +04:30 committed by Andreas Kling
parent cdca6fc113
commit e1cf51b0bd
2 changed files with 4 additions and 1 deletions

View file

@ -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]); auto completion_utility_name = String::formatted("_complete_{}", completion_command.argv[0]);
if (binary_search(cached_path, completion_utility_name)) if (binary_search(cached_path, completion_utility_name))
completion_command.argv[0] = 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", "--" }); completion_command.argv.extend({ "--complete", "--" });

View file

@ -56,7 +56,8 @@
#define ENUMERATE_SHELL_OPTIONS() \ #define ENUMERATE_SHELL_OPTIONS() \
__ENUMERATE_SHELL_OPTION(inline_exec_keep_empty_segments, false, "Keep empty segments in inline execute $(...)") \ __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() \ #define ENUMERATE_SHELL_IMMEDIATE_FUNCTIONS() \
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(concat_lists) \ __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(concat_lists) \