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

Diff for /src/usr.bin/script/script.c between version 1.33 and 1.34

version 1.33, 2017/04/12 14:49:05 version 1.34, 2018/01/21 20:18:20
Line 89 
Line 89 
   
 __dead void done(int);  __dead void done(int);
 void dooutput(void);  void dooutput(void);
 void doshell(void);  void doshell(char *);
 void fail(void);  void fail(void);
 void finish(int);  void finish(int);
 void scriptflush(int);  void scriptflush(int);
Line 102 
Line 102 
         struct sigaction sa;          struct sigaction sa;
         struct winsize win;          struct winsize win;
         char ibuf[BUFSIZ];          char ibuf[BUFSIZ];
           char *cmd;
         ssize_t cc, off;          ssize_t cc, off;
         int aflg, ch;          int aflg, ch;
   
           cmd = NULL;
         aflg = 0;          aflg = 0;
         while ((ch = getopt(argc, argv, "a")) != -1)          while ((ch = getopt(argc, argv, "ac:")) != -1)
                 switch(ch) {                  switch(ch) {
                 case 'a':                  case 'a':
                         aflg = 1;                          aflg = 1;
                         break;                          break;
                   case 'c':
                           cmd = optarg;
                           break;
                 default:                  default:
                         fprintf(stderr, "usage: %s [-a] [file]\n", __progname);                          fprintf(stderr, "usage: %s [-a] [-c command] [file]\n",
                               __progname);
                         exit(1);                          exit(1);
                 }                  }
         argc -= optind;          argc -= optind;
Line 163 
Line 169 
                 if (child)                  if (child)
                         dooutput();                          dooutput();
                 else                  else
                         doshell();                          doshell(cmd);
         }          }
   
         bzero(&sa, sizeof sa);          bzero(&sa, sizeof sa);
Line 196 
Line 202 
         done(sigdeadstatus);          done(sigdeadstatus);
 }  }
   
 /* ARGSUSED */  
 void  void
 finish(int signo)  finish(int signo)
 {  {
Line 215 
Line 220 
         errno = save_errno;          errno = save_errno;
 }  }
   
 /* ARGSUSED */  
 void  void
 handlesigwinch(int signo)  handlesigwinch(int signo)
 {  {
Line 294 
Line 298 
         done(0);          done(0);
 }  }
   
 /* ARGSUSED */  
 void  void
 scriptflush(int signo)  scriptflush(int signo)
 {  {
Line 302 
Line 305 
 }  }
   
 void  void
 doshell(void)  doshell(char *cmd)
 {  {
         char *shell;          char *shell;
           char *argp[] = {"sh", "-c", NULL, NULL};
   
         shell = getenv("SHELL");          shell = getenv("SHELL");
         if (shell == NULL)          if (shell == NULL)
Line 313 
Line 317 
         (void)close(master);          (void)close(master);
         (void)fclose(fscript);          (void)fclose(fscript);
         login_tty(slave);          login_tty(slave);
         execl(shell, shell, "-i", (char *)NULL);  
         warn("%s", shell);          if (cmd != NULL) {
                   argp[2] = cmd;
                   execv(_PATH_BSHELL, argp);
                   warn("unable to execute %s", _PATH_BSHELL);
           } else {
                   execl(shell, shell, "-i", (char *)NULL);
                   warn("%s", shell);
           }
         fail();          fail();
 }  }
   

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34