diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2023-04-29 20:33:37 +0330 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2023-05-05 09:35:24 +0330 |
commit | 24c7995743116a79672ce7c930fe0781522c893b (patch) | |
tree | da259caef7d540ff7eeba389ae694617c225eabf | |
parent | 4d00b372c84533a5ac6fae272f2ff3f23782a6bc (diff) | |
download | serenity-24c7995743116a79672ce7c930fe0781522c893b.zip |
Shell: Rename the verb {lookup => look_up}
-rw-r--r-- | Userland/Shell/AST.cpp | 6 | ||||
-rw-r--r-- | Userland/Shell/Builtin.cpp | 26 | ||||
-rw-r--r-- | Userland/Shell/ImmediateFunctions.cpp | 2 | ||||
-rw-r--r-- | Userland/Shell/Shell.cpp | 8 | ||||
-rw-r--r-- | Userland/Shell/Shell.h | 2 |
5 files changed, 22 insertions, 22 deletions
diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index 572e7cfa5b..5bfef43ef1 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -3842,7 +3842,7 @@ ErrorOr<NonnullRefPtr<Value>> SimpleVariableValue::resolve_without_cast(RefPtr<S { VERIFY(shell); - if (auto value = TRY(shell->lookup_local_variable(m_name))) { + if (auto value = TRY(shell->look_up_local_variable(m_name))) { auto result = value.release_nonnull(); // If a slice is applied, add it. if (!m_slices.is_empty()) @@ -3884,11 +3884,11 @@ ErrorOr<Vector<String>> SpecialVariableValue::resolve_as_list(RefPtr<Shell> shel case '$': return { resolve_slices(shell, Vector { TRY(String::number(getpid())) }, m_slices) }; case '*': - if (auto argv = TRY(shell->lookup_local_variable("ARGV"sv))) + if (auto argv = TRY(shell->look_up_local_variable("ARGV"sv))) return resolve_slices(shell, TRY(const_cast<Value&>(*argv).resolve_as_list(shell)), m_slices); return resolve_slices(shell, Vector<String> {}, m_slices); case '#': - if (auto argv = TRY(shell->lookup_local_variable("ARGV"sv))) { + if (auto argv = TRY(shell->look_up_local_variable("ARGV"sv))) { if (argv->is_list()) { auto list_argv = static_cast<AST::ListValue const*>(argv.ptr()); return { resolve_slices(shell, Vector { TRY(String::number(list_argv->values().size())) }, m_slices) }; diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index 78a525ae8f..30fdbcd552 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -83,13 +83,13 @@ static Vector<DeprecatedString> find_matching_executables_in_path(StringView fil ErrorOr<int> Shell::builtin_where(Main::Arguments arguments) { - Vector<StringView> values_to_lookup; + Vector<StringView> values_to_look_up; bool do_only_path_search { false }; bool do_follow_symlinks { false }; bool do_print_only_type { false }; Core::ArgsParser parser; - parser.add_positional_argument(values_to_lookup, "List of shell builtins, aliases or executables", "arguments"); + parser.add_positional_argument(values_to_look_up, "List of shell builtins, aliases or executables", "arguments"); parser.add_option(do_only_path_search, "Search only for executables in the PATH environment variable", "path-only", 'p'); parser.add_option(do_follow_symlinks, "Follow symlinks and print the symlink free path", "follow-symlink", 's'); parser.add_option(do_print_only_type, "Print the argument type instead of a human readable description", "type", 'w'); @@ -97,13 +97,13 @@ ErrorOr<int> Shell::builtin_where(Main::Arguments arguments) if (!parser.parse(arguments, Core::ArgsParser::FailureBehavior::PrintUsage)) return 1; - auto const lookup_alias = [do_only_path_search, &m_aliases = this->m_aliases](StringView alias) -> Optional<DeprecatedString> { + auto const look_up_alias = [do_only_path_search, &m_aliases = this->m_aliases](StringView alias) -> Optional<DeprecatedString> { if (do_only_path_search) return {}; return m_aliases.get(alias); }; - auto const lookup_builtin = [do_only_path_search](StringView builtin) -> Optional<DeprecatedString> { + auto const look_up_builtin = [do_only_path_search](StringView builtin) -> Optional<DeprecatedString> { if (do_only_path_search) return {}; for (auto const& _builtin : builtin_names) { @@ -115,8 +115,8 @@ ErrorOr<int> Shell::builtin_where(Main::Arguments arguments) }; bool at_least_one_succeded { false }; - for (auto const& argument : values_to_lookup) { - auto const alias = lookup_alias(argument); + for (auto const& argument : values_to_look_up) { + auto const alias = look_up_alias(argument); if (alias.has_value()) { if (do_print_only_type) outln("{}: alias", argument); @@ -125,7 +125,7 @@ ErrorOr<int> Shell::builtin_where(Main::Arguments arguments) at_least_one_succeded = true; } - auto const builtin = lookup_builtin(argument); + auto const builtin = look_up_builtin(argument); if (builtin.has_value()) { if (do_print_only_type) outln("{}: builtin", builtin.value()); @@ -588,7 +588,7 @@ ErrorOr<int> Shell::builtin_export(Main::Arguments arguments) } if (parts.size() == 1) { - auto value = TRY(lookup_local_variable(parts[0])); + auto value = TRY(look_up_local_variable(parts[0])); if (value) { auto values = TRY(const_cast<AST::Value&>(*value).resolve_as_list(*this)); StringBuilder builder; @@ -974,7 +974,7 @@ ErrorOr<int> Shell::builtin_shift(Main::Arguments arguments) if (count < 1) return 0; - auto argv_ = TRY(lookup_local_variable("ARGV"sv)); + auto argv_ = TRY(look_up_local_variable("ARGV"sv)); if (!argv_) { warnln("shift: ARGV is unset"); return 1; @@ -1007,7 +1007,7 @@ ErrorOr<int> Shell::builtin_source(Main::Arguments arguments) if (!parser.parse(arguments)) return 1; - auto previous_argv = TRY(lookup_local_variable("ARGV"sv)); + auto previous_argv = TRY(look_up_local_variable("ARGV"sv)); ScopeGuard guard { [&] { if (!args.is_empty()) set_local_variable("ARGV", const_cast<AST::Value&>(*previous_argv)); @@ -1203,7 +1203,7 @@ ErrorOr<int> Shell::builtin_unset(Main::Arguments arguments) if (!did_touch_path && value == "PATH"sv) did_touch_path = true; - if (TRY(lookup_local_variable(value)) != nullptr) { + if (TRY(look_up_local_variable(value)) != nullptr) { unset_local_variable(value); } else if (!unset_only_variables) { unsetenv(value.characters()); @@ -1412,7 +1412,7 @@ ErrorOr<int> Shell::builtin_argsparser_parse(Main::Arguments arguments) }; auto enlist = [&](auto name, auto value) -> ErrorOr<NonnullRefPtr<AST::Value>> { - auto variable = TRY(lookup_local_variable(name)); + auto variable = TRY(look_up_local_variable(name)); if (variable) { auto list = TRY(const_cast<AST::Value&>(*variable).resolve_as_list(*this)); auto new_value = TRY(value->resolve_as_string(*this)); @@ -1791,7 +1791,7 @@ ErrorOr<int> Shell::builtin_read(Main::Arguments arguments) if (auto const* value_from_env = getenv("IFS"); value_from_env) split_by_any_of = TRY(String::from_utf8({ value_from_env, strlen(value_from_env) })); - else if (auto split_by_variable = TRY(lookup_local_variable("IFS"sv)); split_by_variable) + else if (auto split_by_variable = TRY(look_up_local_variable("IFS"sv)); split_by_variable) split_by_any_of = TRY(const_cast<AST::Value&>(*split_by_variable).resolve_as_string(*this)); auto file = TRY(Core::File::standard_input()); diff --git a/Userland/Shell/ImmediateFunctions.cpp b/Userland/Shell/ImmediateFunctions.cpp index 5be2d7a8a0..557e543bb1 100644 --- a/Userland/Shell/ImmediateFunctions.cpp +++ b/Userland/Shell/ImmediateFunctions.cpp @@ -1245,7 +1245,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_math(AST::ImmediateExpression& invok [&](String const& name) -> ErrorOr<i64> { size_t resolution_attempts_remaining = 100; for (auto resolved_name = name; resolution_attempts_remaining > 0; --resolution_attempts_remaining) { - auto value = TRY(lookup_local_variable(resolved_name.bytes_as_string_view())); + auto value = TRY(look_up_local_variable(resolved_name.bytes_as_string_view())); if (!value) break; diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index 5c0caa7415..32d7280d5d 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -352,7 +352,7 @@ Shell::LocalFrame* Shell::find_frame_containing_local_variable(StringView name) return nullptr; } -ErrorOr<RefPtr<AST::Value const>> Shell::lookup_local_variable(StringView name) const +ErrorOr<RefPtr<AST::Value const>> Shell::look_up_local_variable(StringView name) const { if (auto* frame = find_frame_containing_local_variable(name)) return frame->local_variables.get(name).value(); @@ -369,7 +369,7 @@ ErrorOr<RefPtr<AST::Value const>> Shell::get_argument(size_t index) const return adopt_ref(*new AST::StringValue(TRY(String::from_deprecated_string(current_script)))); --index; - if (auto argv = TRY(lookup_local_variable("ARGV"sv))) { + if (auto argv = TRY(look_up_local_variable("ARGV"sv))) { if (argv->is_list_without_resolution()) { AST::ListValue const* list = static_cast<AST::ListValue const*>(argv.ptr()); if (list->values().size() <= index) @@ -389,7 +389,7 @@ ErrorOr<RefPtr<AST::Value const>> Shell::get_argument(size_t index) const ErrorOr<DeprecatedString> Shell::local_variable_or(StringView name, DeprecatedString const& replacement) const { - auto value = TRY(lookup_local_variable(name)); + auto value = TRY(look_up_local_variable(name)); if (value) { StringBuilder builder; builder.join(' ', TRY(const_cast<AST::Value&>(*value).resolve_as_list(const_cast<Shell&>(*this)))); @@ -1095,7 +1095,7 @@ bool Shell::is_allowed_to_modify_termios(const AST::Command& command) const if (command.argv.is_empty()) return false; - auto value = lookup_local_variable("PROGRAMS_ALLOWED_TO_MODIFY_DEFAULT_TERMIOS"sv); + auto value = look_up_local_variable("PROGRAMS_ALLOWED_TO_MODIFY_DEFAULT_TERMIOS"sv); if (value.is_error()) return false; diff --git a/Userland/Shell/Shell.h b/Userland/Shell/Shell.h index d705f90bea..a34a84f968 100644 --- a/Userland/Shell/Shell.h +++ b/Userland/Shell/Shell.h @@ -183,7 +183,7 @@ public: static bool has_history_event(StringView); ErrorOr<RefPtr<AST::Value const>> get_argument(size_t) const; - ErrorOr<RefPtr<AST::Value const>> lookup_local_variable(StringView) const; + ErrorOr<RefPtr<AST::Value const>> look_up_local_variable(StringView) const; ErrorOr<DeprecatedString> local_variable_or(StringView, DeprecatedString const&) const; void set_local_variable(DeprecatedString const&, RefPtr<AST::Value>, bool only_in_current_frame = false); void unset_local_variable(StringView, bool only_in_current_frame = false); |