Line | |
---|
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 | extern char **environ;
|
---|
13 |
|
---|
14 | int printenv_main(int argc, char **argv);
|
---|
15 | int printenv_main(int argc, char **argv)
|
---|
16 | {
|
---|
17 | /* no variables specified, show whole env */
|
---|
18 | if (argc == 1) {
|
---|
19 | int e = 0;
|
---|
20 | while (environ[e])
|
---|
21 | puts(environ[e++]);
|
---|
22 | } else {
|
---|
23 | /* search for specified variables and print them out if found */
|
---|
24 | char *arg, *env;
|
---|
25 |
|
---|
26 | while ((arg = *++argv) != NULL) {
|
---|
27 | env = getenv(arg);
|
---|
28 | if (env)
|
---|
29 | puts(env);
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | fflush_stdout_and_exit(0);
|
---|
34 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.