Last change
on this file since 3862 was 3320, checked in by Bruno Cornec, 10 years ago |
- Re-add (thanks git BTW) the 2.2.9 branch which had been destroyed in
the move to 3.0
|
-
Property svn:eol-style
set to
native
|
File size:
882 bytes
|
Rev | Line | |
---|
[3320] | 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 source tree.
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #include "libbb.h"
|
---|
| 12 |
|
---|
| 13 | /* This is a NOFORK applet. Be very careful! */
|
---|
| 14 |
|
---|
| 15 | int printenv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
---|
| 16 | int printenv_main(int argc UNUSED_PARAM, char **argv)
|
---|
| 17 | {
|
---|
| 18 | int exit_code = EXIT_SUCCESS;
|
---|
| 19 |
|
---|
| 20 | /* no variables specified, show whole env */
|
---|
| 21 | if (!argv[1]) {
|
---|
| 22 | int e = 0;
|
---|
| 23 | while (environ[e])
|
---|
| 24 | puts(environ[e++]);
|
---|
| 25 | } else {
|
---|
| 26 | /* search for specified variables and print them out if found */
|
---|
| 27 | char *arg, *env;
|
---|
| 28 |
|
---|
| 29 | while ((arg = *++argv) != NULL) {
|
---|
| 30 | env = getenv(arg);
|
---|
| 31 | if (env)
|
---|
| 32 | puts(env);
|
---|
| 33 | else
|
---|
| 34 | exit_code = EXIT_FAILURE;
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | fflush_stdout_and_exit(exit_code);
|
---|
| 39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.