From 93df6a585eea73fb97789da3545ddd1a5772ff6e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 14 May 2018 12:01:15 +0200 Subject: script: cleanup done timestamp message * always save "done" timestamp to typescript (use done() for this) * use FORMAT_TIMESTAMP_MAX as buffer size Signed-off-by: Karel Zak --- term-utils/script.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'term-utils') diff --git a/term-utils/script.c b/term-utils/script.c index c7d951d2e..20c35d955 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -225,6 +225,14 @@ static void __attribute__((__noreturn__)) done(struct script_control *ctl) restore_tty(ctl, TCSADRAIN); + if (ctl->typescriptfp) { + char buf[FORMAT_TIMESTAMP_MAX]; + time_t tvec = script_time((time_t *)NULL); + + strtime_iso(&tvec, ISO_TIMESTAMP, buf, sizeof(buf)); + fprintf(ctl->typescriptfp, _("\nScript done on %s\n"), buf); + } + if (!ctl->quiet && ctl->typescriptfp) printf(_("Script done, file is %s\n"), ctl->fname); #ifdef HAVE_LIBUTEMPTER @@ -457,7 +465,6 @@ static void do_io(struct script_control *ctl) { int ret, eof = 0; time_t tvec = script_time((time_t *)NULL); - char buf[128]; enum { POLLFD_SIGNAL = 0, POLLFD_MASTER, @@ -490,6 +497,7 @@ static void do_io(struct script_control *ctl) if (ctl->typescriptfp) { + char buf[FORMAT_TIMESTAMP_MAX]; strtime_iso(&tvec, ISO_TIMESTAMP, buf, sizeof(buf)); fprintf(ctl->typescriptfp, _("Script started on %s\n"), buf); } @@ -560,11 +568,6 @@ static void do_io(struct script_control *ctl) if (!ctl->die) wait_for_child(ctl, 1); - if (ctl->typescriptfp) { - tvec = script_time((time_t *)NULL); - strtime_iso(&tvec, ISO_TIMESTAMP, buf, sizeof(buf)); - fprintf(ctl->typescriptfp, _("\nScript done on %s\n"), buf); - } done(ctl); } -- cgit v1.2.3-55-g7522