Magellan Linux

Contents of /tags/mkinitrd-6_1_5/busybox/coreutils/printenv.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 899 - (show annotations) (download)
Wed Aug 5 17:52:52 2009 UTC (14 years, 10 months ago) by niro
File MIME type: text/plain
File size: 774 byte(s)
tagged 'mkinitrd-6_1_5'
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 /* no variables specified, show whole env */
17 if (!argv[1]) {
18 int e = 0;
19 while (environ[e])
20 puts(environ[e++]);
21 } else {
22 /* search for specified variables and print them out if found */
23 char *arg, *env;
24
25 while ((arg = *++argv) != NULL) {
26 env = getenv(arg);
27 if (env)
28 puts(env);
29 }
30 }
31
32 fflush_stdout_and_exit(EXIT_SUCCESS);
33 }