userspace: Implement `env` as an executable

This commit is contained in:
Bananymous 2024-10-15 23:41:18 +03:00
parent 8fd0162393
commit a6aa048be0
3 changed files with 23 additions and 0 deletions

View File

@ -8,6 +8,7 @@ set(USERSPACE_PROGRAMS
dhcp-client
DynamicLoader
echo
env
getopt
http-server
id

9
userspace/programs/env/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,9 @@
set(SOURCES
main.cpp
)
add_executable(env ${SOURCES})
banan_link_library(env ban)
banan_link_library(env libc)
install(TARGETS env OPTIONAL)

13
userspace/programs/env/main.cpp vendored Normal file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
extern char** environ;
int main()
{
if (!environ)
return 0;
char** current = environ;
while (*current)
printf("%s\n", *current++);
return 0;
}