diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index 74c1485e29..9d7fcb36f0 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -636,8 +637,8 @@ ErrorOr Shell::builtin_export(Main::Arguments arguments) return 1; if (vars.is_empty()) { - for (size_t i = 0; environ[i]; ++i) - puts(environ[i]); + for (auto entry : Core::Environment::entries()) + outln("{}", entry.full_entry); return 0; } diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index 9b4a5f1e14..05a26e8d41 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1726,13 +1727,11 @@ Vector Shell::complete_variable(StringView name, siz } // Look at the environment. - for (auto i = 0; environ[i]; ++i) { - StringView entry { environ[i], strlen(environ[i]) }; - if (entry.starts_with(pattern)) { - auto parts = entry.split_view('='); - if (parts.is_empty() || parts.first().is_empty()) + for (auto entry : Core::Environment::entries()) { + if (entry.full_entry.starts_with(pattern)) { + if (entry.name.is_empty()) continue; - ByteString name = parts.first(); + auto name = entry.name.to_byte_string(); if (suggestions.contains_slow(name)) continue; suggestions.append(move(name));