diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2023-03-01 00:11:43 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-01 10:47:19 +0100 |
commit | 500044906d1b90f1c8b1a2f5675a2f82ab92b758 (patch) | |
tree | 7d6aae259b188c1b6879c591eebdfd7f55d9b71c /Userland/Applications/Terminal | |
parent | 60908adcbe2afd611233957bb3126f736eb18e25 (diff) | |
download | serenity-500044906d1b90f1c8b1a2f5675a2f82ab92b758.zip |
LibCore+Everywhere: Remove ArgsParser::add*(char const*&)
This is not guaranteed to always work correctly as ArgsParser deals in
StringViews and might have a non-properly-null-terminated string as a
value. As a bonus, using StringView (and DeprecatedString where
necessary) leads to nicer looking code too :^)
Diffstat (limited to 'Userland/Applications/Terminal')
-rw-r--r-- | Userland/Applications/Terminal/main.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index 3aa8f7d6cf..343c13913b 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -251,7 +251,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) Config::pledge_domain("Terminal"); - char const* command_to_execute = nullptr; + StringView command_to_execute; bool keep_open = false; Core::ArgsParser args_parser; @@ -260,7 +260,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.parse(arguments); - if (keep_open && !command_to_execute) { + if (keep_open && command_to_execute.is_empty()) { warnln("Option -k can only be used in combination with -e."); return 1; } @@ -273,7 +273,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } if (shell_pid == 0) { close(ptm_fd); - if (command_to_execute) + if (!command_to_execute.is_empty()) TRY(run_command(command_to_execute, keep_open)); else TRY(run_command(Config::read_string("Terminal"sv, "Startup"sv, "Command"sv, ""sv), false)); |