userspace: Implement env as an executable
This commit is contained in:
@@ -8,6 +8,7 @@ set(USERSPACE_PROGRAMS
|
|||||||
dhcp-client
|
dhcp-client
|
||||||
DynamicLoader
|
DynamicLoader
|
||||||
echo
|
echo
|
||||||
|
env
|
||||||
getopt
|
getopt
|
||||||
http-server
|
http-server
|
||||||
id
|
id
|
||||||
|
|||||||
9
userspace/programs/env/CMakeLists.txt
vendored
Normal file
9
userspace/programs/env/CMakeLists.txt
vendored
Normal 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
13
userspace/programs/env/main.cpp
vendored
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user