mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 07:54:58 +00:00
Shell: Use Core::Environment instead of manually iterating environ
This commit is contained in:
parent
97cb9cf469
commit
40b04d4da5
2 changed files with 8 additions and 8 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <AK/ScopeGuard.h>
|
#include <AK/ScopeGuard.h>
|
||||||
#include <AK/Statistics.h>
|
#include <AK/Statistics.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/Environment.h>
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
|
@ -636,8 +637,8 @@ ErrorOr<int> Shell::builtin_export(Main::Arguments arguments)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (vars.is_empty()) {
|
if (vars.is_empty()) {
|
||||||
for (size_t i = 0; environ[i]; ++i)
|
for (auto entry : Core::Environment::entries())
|
||||||
puts(environ[i]);
|
outln("{}", entry.full_entry);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
#include <LibCore/DateTime.h>
|
#include <LibCore/DateTime.h>
|
||||||
#include <LibCore/DirIterator.h>
|
#include <LibCore/DirIterator.h>
|
||||||
|
#include <LibCore/Environment.h>
|
||||||
#include <LibCore/Event.h>
|
#include <LibCore/Event.h>
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
|
@ -1726,13 +1727,11 @@ Vector<Line::CompletionSuggestion> Shell::complete_variable(StringView name, siz
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look at the environment.
|
// Look at the environment.
|
||||||
for (auto i = 0; environ[i]; ++i) {
|
for (auto entry : Core::Environment::entries()) {
|
||||||
StringView entry { environ[i], strlen(environ[i]) };
|
if (entry.full_entry.starts_with(pattern)) {
|
||||||
if (entry.starts_with(pattern)) {
|
if (entry.name.is_empty())
|
||||||
auto parts = entry.split_view('=');
|
|
||||||
if (parts.is_empty() || parts.first().is_empty())
|
|
||||||
continue;
|
continue;
|
||||||
ByteString name = parts.first();
|
auto name = entry.name.to_byte_string();
|
||||||
if (suggestions.contains_slow(name))
|
if (suggestions.contains_slow(name))
|
||||||
continue;
|
continue;
|
||||||
suggestions.append(move(name));
|
suggestions.append(move(name));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue