Author: bdrewery
Date: Mon Mar 28 16:24:10 2016
New Revision: 297353
URL: https://svnweb.freebsd.org/changeset/base/297353

Log:
  MFC r296526:
  
    Record command exit status in the typescript file when running simple
    commands.
  
  Relnotes:     yes

Modified:
  stable/9/usr.bin/script/script.c
Directory Properties:
  stable/9/usr.bin/script/   (props changed)

Modified: stable/9/usr.bin/script/script.c
==============================================================================
--- stable/9/usr.bin/script/script.c    Mon Mar 28 16:21:45 2016        
(r297352)
+++ stable/9/usr.bin/script/script.c    Mon Mar 28 16:24:10 2016        
(r297353)
@@ -74,7 +74,7 @@ static int child;
 static const char *fname;
 static char *fmfname;
 static int fflg, qflg, ttyflg;
-static int usesleep, rawout;
+static int usesleep, rawout, showexit;
 
 static struct termios tt;
 
@@ -108,6 +108,7 @@ main(int argc, char *argv[])
        flushtime = 30;
        fm_fd = -1;     /* Shut up stupid "may be used uninitialized" GCC
                           warning. (not needed w/clang) */
+       showexit = 0;
 
        while ((ch = getopt(argc, argv, "adfkpqrt:")) != -1)
                switch(ch) {
@@ -196,7 +197,8 @@ main(int argc, char *argv[])
                        (void)fprintf(fscript, "Script started on %s",
                            ctime(&tvec));
                        if (argv[0]) {
-                               fprintf(fscript, "command: ");
+                               showexit = 1;
+                               fprintf(fscript, "Command: ");
                                for (k = 0 ; argv[k] ; ++k)
                                        fprintf(fscript, "%s%s", k ? " " : "",
                                                argv[k]);
@@ -357,9 +359,13 @@ done(int eno)
        if (rawout)
                record(fscript, NULL, 0, 'e');
        if (!qflg) {
-               if (!rawout)
+               if (!rawout) {
+                       if (showexit)
+                               (void)fprintf(fscript, "\nCommand exit status:"
+                                   " %d", eno);
                        (void)fprintf(fscript,"\nScript done on %s",
                            ctime(&tvec));
+               }
                (void)printf("\nScript done, output file is %s\n", fname);
                if (fflg) {
                        (void)printf("Filemon done, output file is %s\n",
_______________________________________________
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"

Reply via email to