[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.4 and 1.5

version 1.4, 1997/06/20 04:54:59 version 1.5, 2000/09/15 07:13:48
Line 52 
Line 52 
 #include <locale.h>  #include <locale.h>
 #include <errno.h>  #include <errno.h>
   
 static void usage __P((void));  void usage __P((void));
   
 int  int
 main(argc, argv)  main(argc, argv)
Line 71 
Line 71 
                 case '-':                       /* obsolete */                  case '-':                       /* obsolete */
                 case 'i':                  case 'i':
                         if ((environ = (char **)calloc(1, sizeof(char *))) == NULL)                          if ((environ = (char **)calloc(1, sizeof(char *))) == NULL)
                                 err(1, "calloc");                                  err(126, "calloc");
                         break;                          break;
                 case '?':                  case '?':
                 default:                  default:
Line 79 
Line 79 
                 }                  }
   
         for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)          for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)
                 (void)setenv(*argv, ++p, 1);                  if (setenv(*argv, ++p, 1) == -1) {
                           /* reuse 126, it matches the problem most */
                           exit(126);
                   }
   
         if (*argv) {          if (*argv) {
                 /* return 127 if the command to be run could not be found; 126                  /*
                    if the command was was found but could not be invoked */                   * return 127 if the command to be run could not be
                    * found; 126 if the command was found but could
                    * not be invoked
                    */
                 execvp(*argv, argv);                  execvp(*argv, argv);
                 err((errno == ENOENT) ? 127 : 126, "%s", *argv);                  err((errno == ENOENT) ? 127 : 126, "%s", *argv);
                 /* NOTREACHED */                  /* NOTREACHED */
Line 96 
Line 101 
         exit(0);          exit(0);
 }  }
   
 static void  void
 usage ()  usage()
 {  {
         (void) fprintf(stderr, "usage: env [-i] [name=value ...] [command]\n");          (void) fprintf(stderr, "usage: env [-i] [name=value ...] [command]\n");
         exit (1);          exit (1);

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5