summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2018-05-14 12:01:15 +0200
committerKarel Zak2018-05-14 12:01:15 +0200
commit93df6a585eea73fb97789da3545ddd1a5772ff6e (patch)
treec94ac1797791f219d5c25bce62fe94f08db5d5e5
parenttests: remove debug stuff from ts/script/options (diff)
downloadkernel-qcow2-util-linux-93df6a585eea73fb97789da3545ddd1a5772ff6e.tar.gz
kernel-qcow2-util-linux-93df6a585eea73fb97789da3545ddd1a5772ff6e.tar.xz
kernel-qcow2-util-linux-93df6a585eea73fb97789da3545ddd1a5772ff6e.zip
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 <kzak@redhat.com>
-rw-r--r--term-utils/script.c15
1 files changed, 9 insertions, 6 deletions
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);
}