source: MondoRescue/branches/2.2.5/mindi-busybox/coreutils/printenv.c@ 3656

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

Update to busybox 1.7.2

File size: 750 bytes
RevLine 
[1765]1/* vi: set sw=4 ts=4: */
[821]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 *
[1765]8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
[821]9 */
10
[1765]11#include "libbb.h"
12extern char **environ;
[821]13
[1765]14int printenv_main(int argc, char **argv);
[821]15int printenv_main(int argc, char **argv)
16{
17 /* no variables specified, show whole env */
[1765]18 if (argc == 1) {
19 int e = 0;
[821]20 while (environ[e])
21 puts(environ[e++]);
[1765]22 } else {
23 /* search for specified variables and print them out if found */
[821]24 char *arg, *env;
25
[1765]26 while ((arg = *++argv) != NULL) {
27 env = getenv(arg);
28 if (env)
29 puts(env);
30 }
[821]31 }
32
[1765]33 fflush_stdout_and_exit(0);
[821]34}
Note: See TracBrowser for help on using the repository browser.