mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:57:35 +00:00
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 :^)
This commit is contained in:
parent
60908adcbe
commit
500044906d
43 changed files with 122 additions and 145 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue