mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
Utilities: Use Core::Environment instead of Core::System::*env()
This commit is contained in:
parent
b9dc2d7ebf
commit
7109f3706e
Notes:
sideshowbarker
2024-07-17 06:35:16 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/7109f3706e Pull-request: https://github.com/SerenityOS/serenity/pull/23018 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/DanShaders Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/shannonbooth
@ -8,6 +8,7 @@
|
|||||||
#include <AK/ByteString.h>
|
#include <AK/ByteString.h>
|
||||||
#include <AK/Format.h>
|
#include <AK/Format.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/Environment.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/Clipboard.h>
|
#include <LibGUI/Clipboard.h>
|
||||||
@ -27,7 +28,7 @@ static void spawn_command(Span<StringView> command, ByteBuffer const& data, char
|
|||||||
MUST(Core::System::dup2(pipefd[0], 0));
|
MUST(Core::System::dup2(pipefd[0], 0));
|
||||||
MUST(Core::System::close(pipefd[0]));
|
MUST(Core::System::close(pipefd[0]));
|
||||||
MUST(Core::System::close(pipefd[1]));
|
MUST(Core::System::close(pipefd[1]));
|
||||||
MUST(Core::System::setenv("CLIPBOARD_STATE"sv, { state, strlen(state) }, true));
|
MUST(Core::Environment::set("CLIPBOARD_STATE"sv, { state, strlen(state) }, Core::Environment::Overwrite::Yes));
|
||||||
MUST(Core::System::exec(command[0], command, Core::System::SearchInPath::Yes));
|
MUST(Core::System::exec(command[0], command, Core::System::SearchInPath::Yes));
|
||||||
perror("exec");
|
perror("exec");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/Environment.h>
|
||||||
#include <LibCore/MappedFile.h>
|
#include <LibCore/MappedFile.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibELF/Image.h>
|
#include <LibELF/Image.h>
|
||||||
@ -33,8 +34,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
|
|
||||||
if (add_promises_for_dynamic_linker && TRY(is_dynamically_linked_executable(command[0]))) {
|
if (add_promises_for_dynamic_linker && TRY(is_dynamically_linked_executable(command[0]))) {
|
||||||
auto constexpr loader_promises = "stdio rpath prot_exec"sv;
|
auto constexpr loader_promises = "stdio rpath prot_exec"sv;
|
||||||
MUST(Core::System::setenv("_LOADER_PLEDGE_PROMISES"sv, loader_promises, true));
|
MUST(Core::Environment::set("_LOADER_PLEDGE_PROMISES"sv, loader_promises, Core::Environment::Overwrite::Yes));
|
||||||
MUST(Core::System::setenv("_LOADER_MAIN_PROGRAM_PLEDGE_PROMISES"sv, promises, true));
|
MUST(Core::Environment::set("_LOADER_MAIN_PROGRAM_PLEDGE_PROMISES"sv, promises, Core::Environment::Overwrite::Yes));
|
||||||
promises = ByteString::formatted("{} {}", promises, loader_promises);
|
promises = ByteString::formatted("{} {}", promises, loader_promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibCore/ConfigFile.h>
|
||||||
|
#include <LibCore/Environment.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibCoredump/Backtrace.h>
|
#include <LibCoredump/Backtrace.h>
|
||||||
#include <LibFileSystem/FileSystem.h>
|
#include <LibFileSystem/FileSystem.h>
|
||||||
@ -360,15 +361,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
|
|
||||||
test_glob = ByteString::formatted("*{}*", test_glob);
|
test_glob = ByteString::formatted("*{}*", test_glob);
|
||||||
|
|
||||||
if (getenv("DISABLE_DBG_OUTPUT")) {
|
if (Core::Environment::has("DISABLE_DBG_OUTPUT"sv))
|
||||||
AK::set_debug_enabled(false);
|
AK::set_debug_enabled(false);
|
||||||
}
|
|
||||||
|
|
||||||
// Make UBSAN deadly for all tests we run by default.
|
// Make UBSAN deadly for all tests we run by default.
|
||||||
TRY(Core::System::setenv("UBSAN_OPTIONS"sv, "halt_on_error=1"sv, true));
|
TRY(Core::Environment::set("UBSAN_OPTIONS"sv, "halt_on_error=1"sv, Core::Environment::Overwrite::Yes));
|
||||||
|
|
||||||
if (!run_benchmarks)
|
if (!run_benchmarks)
|
||||||
TRY(Core::System::setenv("TESTS_ONLY"sv, "1"sv, true));
|
TRY(Core::Environment::set("TESTS_ONLY"sv, "1"sv, Core::Environment::Overwrite::Yes));
|
||||||
|
|
||||||
ByteString test_root;
|
ByteString test_root;
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <LibCore/Account.h>
|
#include <LibCore/Account.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/Environment.h>
|
||||||
#include <LibCore/GetPassword.h>
|
#include <LibCore/GetPassword.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibMain/Main.h>
|
#include <LibMain/Main.h>
|
||||||
@ -60,7 +61,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
|
|
||||||
TRY(Core::System::pledge("stdio exec"));
|
TRY(Core::System::pledge("stdio exec"));
|
||||||
|
|
||||||
TRY(Core::System::setenv("HOME"sv, account.home_directory(), true));
|
TRY(Core::Environment::set("HOME"sv, account.home_directory(), Core::Environment::Overwrite::Yes));
|
||||||
|
|
||||||
if (command.is_null()) {
|
if (command.is_null()) {
|
||||||
TRY(Core::System::exec(account.shell(), Array<StringView, 1> { account.shell().view() }, Core::System::SearchInPath::No));
|
TRY(Core::System::exec(account.shell(), Array<StringView, 1> { account.shell().view() }, Core::System::SearchInPath::No));
|
||||||
|
Loading…
Reference in New Issue
Block a user