Userspace: Shell now has 'env' for printing environment

This commit is contained in:
Bananymous 2023-07-06 10:32:43 +03:00
parent 79450df04c
commit 21bd87bb07
1 changed files with 8 additions and 0 deletions

View File

@ -15,6 +15,8 @@
struct termios old_termios, new_termios; struct termios old_termios, new_termios;
extern char** environ;
BAN::Optional<BAN::String> parse_dollar(BAN::StringView command, size_t& i) BAN::Optional<BAN::String> parse_dollar(BAN::StringView command, size_t& i)
{ {
ASSERT(command[i] == '$'); ASSERT(command[i] == '$');
@ -178,6 +180,12 @@ int execute_command(BAN::Vector<BAN::String>& args)
ERROR_RETURN("setenv"); ERROR_RETURN("setenv");
} }
} }
else if (args.front() == "env"sv)
{
char** current = environ;
while (*current)
printf("%s\n", *current++);
}
else if (args.front() == "cd"sv) else if (args.front() == "cd"sv)
{ {
if (args.size() > 2) if (args.size() > 2)