userspace: Implement `env` as an executable
This commit is contained in:
parent
8fd0162393
commit
a6aa048be0
|
@ -8,6 +8,7 @@ set(USERSPACE_PROGRAMS
|
|||
dhcp-client
|
||||
DynamicLoader
|
||||
echo
|
||||
env
|
||||
getopt
|
||||
http-server
|
||||
id
|
||||
|
|
|
@ -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)
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue