diff --git a/Userland/Libraries/LibCore/GetPassword.cpp b/Userland/Libraries/LibCore/GetPassword.cpp index ac923ad681..74b3b5dd29 100644 --- a/Userland/Libraries/LibCore/GetPassword.cpp +++ b/Userland/Libraries/LibCore/GetPassword.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -15,17 +16,13 @@ namespace Core { ErrorOr get_password(StringView prompt) { - if (write(STDOUT_FILENO, prompt.characters_without_null_termination(), prompt.length()) < 0) - return Error::from_errno(errno); + TRY(Core::System::write(STDOUT_FILENO, prompt.bytes())); - termios original {}; - if (tcgetattr(STDIN_FILENO, &original) < 0) - return Error::from_errno(errno); + auto original = TRY(Core::System::tcgetattr(STDIN_FILENO)); termios no_echo = original; no_echo.c_lflag &= ~ECHO; - if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &no_echo) < 0) - return Error::from_errno(errno); + TRY(Core::System::tcsetattr(STDIN_FILENO, TCSAFLUSH, no_echo)); char* password = nullptr; size_t n = 0;