summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2016-03-08 18:05:23 +0000
committerbdrewery <bdrewery@FreeBSD.org>2016-03-08 18:05:23 +0000
commit1d619dcb697aac116b9709634986e7fe26315685 (patch)
tree97bf444e7c3ed3415a6fc0740a5162d3da3f1a29
parent49a860c3b1235560e6919b9b1c5b06dd585f60ce (diff)
downloadFreeBSD-src-1d619dcb697aac116b9709634986e7fe26315685.zip
FreeBSD-src-1d619dcb697aac116b9709634986e7fe26315685.tar.gz
Record command exit status in the typescript file when running simple commands.
Also capitalize 'command:'. Relnotes: yes MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division
-rw-r--r--usr.bin/script/script.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c
index 4c5e402..6ffb46a 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -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;
@@ -107,6 +107,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, "adFfkpqrt:")) != -1)
switch(ch) {
@@ -198,7 +199,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]);
@@ -360,9 +362,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",
OpenPOWER on IntegriCloud