Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/coreutils/env.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 43  static const char env_longopts[] ALIGN1 Line 43  static const char env_longopts[] ALIGN1
43  int env_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;  int env_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
44  int env_main(int argc UNUSED_PARAM, char **argv)  int env_main(int argc UNUSED_PARAM, char **argv)
45  {  {
46   /* cleanenv was static - why? */   unsigned opts;
  char *cleanenv[1];  
  char **ep;  
  unsigned opt;  
47   llist_t *unset_env = NULL;   llist_t *unset_env = NULL;
48    
49   opt_complementary = "u::";   opt_complementary = "u::";
50  #if ENABLE_FEATURE_ENV_LONG_OPTIONS  #if ENABLE_FEATURE_ENV_LONG_OPTIONS
51   applet_long_options = env_longopts;   applet_long_options = env_longopts;
52  #endif  #endif
53   opt = getopt32(argv, "+iu:", &unset_env);   opts = getopt32(argv, "+iu:", &unset_env);
54   argv += optind;   argv += optind;
55   if (*argv && LONE_DASH(argv[0])) {   if (argv[0] && LONE_DASH(argv[0])) {
56   opt |= 1;   opts |= 1;
57   ++argv;   ++argv;
58   }   }
59   if (opt & 1) {   if (opts & 1) {
60   cleanenv[0] = NULL;   clearenv();
61   environ = cleanenv;   }
62   } else {   while (unset_env) {
63   while (unset_env) {   char *var = llist_pop(&unset_env);
64   unsetenv(llist_pop(&unset_env));   /* 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);
70   }   }
71    
72   while (*argv && (strchr(*argv, '=') != NULL)) {   while (*argv && (strchr(*argv, '=') != NULL)) {
# Line 82  int env_main(int argc UNUSED_PARAM, char Line 83  int env_main(int argc UNUSED_PARAM, char
83   bb_simple_perror_msg_and_die(*argv);   bb_simple_perror_msg_and_die(*argv);
84   }   }
85    
86   for (ep = environ; *ep; ep++) {   if (environ) { /* clearenv() may set environ == NULL! */
87   puts(*ep);   char **ep;
88     for (ep = environ; *ep; ep++) {
89     puts(*ep);
90     }
91   }   }
92    
93   fflush_stdout_and_exit(EXIT_SUCCESS);   fflush_stdout_and_exit(EXIT_SUCCESS);

Legend:
Removed from v.983  
changed lines
  Added in v.984