diff options
author | sin-ack <sin-ack@users.noreply.github.com> | 2022-07-11 20:42:03 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-12 23:11:35 +0200 |
commit | 60f6bc902b1c13b6eaa8f27b4a99cd40af6bf5cf (patch) | |
tree | 26ec0ce031f335bcc93a92135dbd02c21687c37e /Userland/Shell | |
parent | fded8f861d7576ceffc818c43bdd62285b569ad0 (diff) | |
download | serenity-60f6bc902b1c13b6eaa8f27b4a99cd40af6bf5cf.zip |
Userland: Convert command line arguments to String/StringView
StringView was used where possible. Some utilities still use libc
functions which expect null-terminated strings, so String objects were
used there instead.
Diffstat (limited to 'Userland/Shell')
-rw-r--r-- | Userland/Shell/main.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Shell/main.cpp b/Userland/Shell/main.cpp index 391e0f3c72..90ec8716bc 100644 --- a/Userland/Shell/main.cpp +++ b/Userland/Shell/main.cpp @@ -157,8 +157,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) }; }; - char const* command_to_run = nullptr; - char const* file_to_read_from = nullptr; + StringView command_to_run = {}; + StringView file_to_read_from = {}; Vector<String> script_args; bool skip_rc_files = false; char const* format = nullptr; @@ -201,10 +201,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } } - auto execute_file = file_to_read_from && "-"sv != file_to_read_from; + auto execute_file = !file_to_read_from.is_empty() && "-"sv != file_to_read_from; attempt_interactive = !execute_file; - if (keep_open && !command_to_run && !execute_file) { + if (keep_open && command_to_run.is_empty() && !execute_file) { warnln("Option --keep-open can only be used in combination with -c or when specifying a file to execute."); return 1; } @@ -230,7 +230,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) shell->set_local_variable("ARGV", adopt_ref(*new Shell::AST::ListValue(move(script_args)))); - if (command_to_run) { + if (!command_to_run.is_empty()) { dbgln("sh -c '{}'\n", command_to_run); auto result = shell->run_command(command_to_run); if (!keep_open) |