source: MondoRescue/branches/2.2.8.selinux/mindi-busybox/coreutils/printenv.c@ 3528

Last change on this file since 3528 was 1765, checked in by Bruno Cornec, 16 years ago

Update to busybox 1.7.2

File size: 750 bytes
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"
12extern char **environ;
13
14int printenv_main(int argc, char **argv);
15int 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.