diff options
author | Karel Zak | 2014-06-23 11:41:31 +0200 |
---|---|---|
committer | Karel Zak | 2014-06-23 11:41:31 +0200 |
commit | cabce4ea7191d4e97d05eda1cb9f95bf4d860533 (patch) | |
tree | 111972d496cf8e0fcb7c593196f4675dbe500c58 /term-utils/script.c | |
parent | script: silence the done message on --quiet as well (diff) | |
download | kernel-qcow2-util-linux-cabce4ea7191d4e97d05eda1cb9f95bf4d860533.tar.gz kernel-qcow2-util-linux-cabce4ea7191d4e97d05eda1cb9f95bf4d860533.tar.xz kernel-qcow2-util-linux-cabce4ea7191d4e97d05eda1cb9f95bf4d860533.zip |
script: clean up code to genenrate Star/Done messages
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils/script.c')
-rw-r--r-- | term-utils/script.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/term-utils/script.c b/term-utils/script.c index 2da75124b..b9f87384a 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -421,7 +421,6 @@ my_strftime(char *buf, size_t len, const char *fmt, const struct tm *tm) { void dooutput(void) { ssize_t cc; - time_t tvec; char obuf[BUFSIZ]; struct timeval tv; double oldtime=time(NULL), newtime; @@ -435,10 +434,11 @@ dooutput(void) { if (tflg && !timingfd) timingfd = fdopen(STDERR_FILENO, "w"); - tvec = time((time_t *)NULL); - my_strftime(obuf, sizeof obuf, "%c\n", localtime(&tvec)); - if (!qflg) + if (!qflg) { + time_t tvec = time((time_t *)NULL); + my_strftime(obuf, sizeof obuf, "%c\n", localtime(&tvec)); fprintf(fscript, _("Script started on %s"), obuf); + } FD_ZERO(&readfds); @@ -575,12 +575,12 @@ done(void) { if (subchild) { /* output process */ if (fscript) { - char buf[BUFSIZ]; - tvec = time((time_t *)NULL); - my_strftime(buf, sizeof buf, "%c\n", localtime(&tvec)); - if (!qflg) + if (!qflg) { + char buf[BUFSIZ]; + tvec = time((time_t *)NULL); + my_strftime(buf, sizeof buf, "%c\n", localtime(&tvec)); fprintf(fscript, _("\nScript done on %s"), buf); - + } if (close_stream(fscript) != 0) errx(EXIT_FAILURE, _("write error")); fscript = NULL; |