Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/coreutils/env.c


Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/coreutils/env.c

    r1765 r2725  
    44 *
    55 * Copyright (c) 1988, 1993, 1994
    6  *  The Regents of the University of California.  All rights reserved.
     6 * The Regents of the University of California.  All rights reserved.
    77 *
    8  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    99 *
    1010 * Original copyright notice is retained at the end of this file.
     
    3030 */
    3131
    32 #include <getopt.h> /* struct option */
    33 extern char **environ;
     32/* This is a NOEXEC applet. Be very careful! */
    3433
    3534#include "libbb.h"
     
    4241#endif
    4342
    44 int env_main(int argc, char** argv);
    45 int env_main(int argc, char** argv)
     43int env_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     44int env_main(int argc UNUSED_PARAM, char **argv)
    4645{
    47     /* cleanenv was static - why? */
    48     char *cleanenv[1];
    49     char **ep;
    50     unsigned opt;
     46    unsigned opts;
    5147    llist_t *unset_env = NULL;
    5248
     
    5551    applet_long_options = env_longopts;
    5652#endif
    57     opt = getopt32(argv, "+iu:", &unset_env);
     53    opts = getopt32(argv, "+iu:", &unset_env);
    5854    argv += optind;
    59     if (*argv && LONE_DASH(argv[0])) {
    60         opt |= 1;
     55    if (argv[0] && LONE_DASH(argv[0])) {
     56        opts |= 1;
    6157        ++argv;
    6258    }
    63     if (opt & 1) {
    64         cleanenv[0] = NULL;
    65         environ = cleanenv;
    66     } else {
    67         while (unset_env) {
    68             unsetenv(unset_env->data);
    69             unset_env = unset_env->link;
    70         }
     59    if (opts & 1) {
     60        clearenv();
     61    }
     62    while (unset_env) {
     63        char *var = llist_pop(&unset_env);
     64        /* This does not handle -uVAR=VAL
     65         * (coreutils _sets_ the variable in that case): */
     66        /*unsetenv(var);*/
     67        /* This does, but uses somewhan undocumented feature that
     68         * putenv("name_without_equal_sign") unsets the variable: */
     69        putenv(var);
    7170    }
    7271
     
    7877    }
    7978
    80     if (*argv) {
    81         BB_EXECVP(*argv, argv);
    82         /* SUSv3-mandated exit codes. */
    83         xfunc_error_retval = (errno == ENOENT) ? 127 : 126;
    84         bb_perror_msg_and_die("%s", *argv);
     79    if (argv[0]) {
     80        BB_EXECVP_or_die(argv);
    8581    }
    8682
    87     for (ep = environ; *ep; ep++) {
    88         puts(*ep);
     83    if (environ) { /* clearenv() may set environ == NULL! */
     84        char **ep;
     85        for (ep = environ; *ep; ep++) {
     86            puts(*ep);
     87        }
    8988    }
    9089
    91     fflush_stdout_and_exit(0);
     90    fflush_stdout_and_exit(EXIT_SUCCESS);
    9291}
    9392
     
    105104 *    documentation and/or other materials provided with the distribution.
    106105 *
    107  * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
    108  *      ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
     106 * 3. BSD Advertising Clause omitted per the July 22, 1999 licensing change
     107 *    ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
    109108 *
    110109 * 4. Neither the name of the University nor the names of its contributors
     
    124123 * SUCH DAMAGE.
    125124 */
    126 
    127 
Note: See TracChangeset for help on using the changeset viewer.