[BACK]Return to env.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / env

Diff for /src/usr.bin/env/env.c between version 1.10 and 1.11

version 1.10, 2003/06/10 22:20:46 version 1.11, 2006/05/28 04:21:13
Line 41 
Line 41 
 #endif /* not lint */  #endif /* not lint */
   
 #include <err.h>  #include <err.h>
   #include <errno.h>
   #include <locale.h>
 #include <stdio.h>  #include <stdio.h>
 #include <string.h>  
 #include <stdlib.h>  #include <stdlib.h>
   #include <string.h>
 #include <unistd.h>  #include <unistd.h>
 #include <locale.h>  
 #include <errno.h>  
   
 void usage(void);  __dead void usage(void);
   
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
Line 60 
Line 60 
   
         setlocale(LC_ALL, "");          setlocale(LC_ALL, "");
   
         while ((ch = getopt(argc, argv, "i-")) != -1)          while ((ch = getopt(argc, argv, "i")) != -1)
                 switch((char)ch) {                  switch(ch) {
                 case '-':                       /* obsolete */  
                 case 'i':                  case 'i':
                         if ((environ = (char **)calloc(1, sizeof(char *))) == NULL)                          if ((environ = calloc(1, sizeof(char *))) == NULL)
                                 err(126, "calloc");                                  err(126, "calloc");
                         break;                          break;
                 case '?':  
                 default:                  default:
                         usage();                          usage();
                 }                  }
           argc -= optind;
           argv += optind;
   
         for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)          for (; *argv && (p = strchr(*argv, '=')); ++argv)
                 if (setenv(*argv, ++p, 1) == -1) {                  if (setenv(*argv, ++p, 1) == -1) {
                         /* reuse 126, it matches the problem most */                          /* reuse 126, it matches the problem most */
                         exit(126);                          exit(126);
Line 86 
Line 86 
                  */                   */
                 execvp(*argv, argv);                  execvp(*argv, argv);
                 err((errno == ENOENT) ? 127 : 126, "%s", *argv);                  err((errno == ENOENT) ? 127 : 126, "%s", *argv);
                 /* NOTREACHED */  
         }          }
   
         for (ep = environ; *ep; ep++)          for (ep = environ; *ep; ep++)
Line 98 
Line 97 
 void  void
 usage(void)  usage(void)
 {  {
         (void)fprintf(stderr, "usage: env [-i] [name=value ...] "          extern char *__progname;
             "[utility [argument ...]]\n");  
         exit (1);          (void)fprintf(stderr, "usage: %s [-i] [name=value ...] "
               "[utility [argument ...]]\n", __progname);
           exit(1);
 }  }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11