Contents of /tags/mkinitrd-6_2_3/busybox/coreutils/printenv.c
Parent Directory | Revision Log
Revision 1054 -
(show annotations)
(download)
Mon May 31 20:54:44 2010 UTC (14 years, 3 months ago) by niro
File MIME type: text/plain
File size: 841 byte(s)
Mon May 31 20:54:44 2010 UTC (14 years, 3 months ago) by niro
File MIME type: text/plain
File size: 841 byte(s)
tagged 'mkinitrd-6_2_3'
1 | /* vi: set sw=4 ts=4: */ |
2 | /* |
3 | * printenv implementation for busybox |
4 | * |
5 | * Copyright (C) 2005 by Erik Andersen <andersen@codepoet.org> |
6 | * Copyright (C) 2005 by Mike Frysinger <vapier@gentoo.org> |
7 | * |
8 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
9 | */ |
10 | |
11 | #include "libbb.h" |
12 | |
13 | int printenv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
14 | int printenv_main(int argc UNUSED_PARAM, char **argv) |
15 | { |
16 | int exit_code = EXIT_SUCCESS; |
17 | |
18 | /* no variables specified, show whole env */ |
19 | if (!argv[1]) { |
20 | int e = 0; |
21 | while (environ[e]) |
22 | puts(environ[e++]); |
23 | } else { |
24 | /* search for specified variables and print them out if found */ |
25 | char *arg, *env; |
26 | |
27 | while ((arg = *++argv) != NULL) { |
28 | env = getenv(arg); |
29 | if (env) |
30 | puts(env); |
31 | else |
32 | exit_code = EXIT_FAILURE; |
33 | } |
34 | } |
35 | |
36 | fflush_stdout_and_exit(exit_code); |
37 | } |