summaryrefslogtreecommitdiffstats
path: root/term-utils/script.c
diff options
context:
space:
mode:
authorRui Zhao (renyuneyun)2017-04-14 18:43:41 +0200
committerRui Zhao (renyuneyun)2017-04-14 18:49:25 +0200
commitbdef362d5d6c2c899fc23270d9be10968a0cbdc2 (patch)
treee8e1bb53df3a6c8330351b11480ee282091cb43a /term-utils/script.c
parentscript: don't call strftime() if not necessary (diff)
downloadkernel-qcow2-util-linux-bdef362d5d6c2c899fc23270d9be10968a0cbdc2.tar.gz
kernel-qcow2-util-linux-bdef362d5d6c2c899fc23270d9be10968a0cbdc2.tar.xz
kernel-qcow2-util-linux-bdef362d5d6c2c899fc23270d9be10968a0cbdc2.zip
fix the position of newline in the time output of 'script'
- move '\n' to fprintf - use `timeutils/strtime_iso()` instead of `strtime()` Signed-off-by: Rui Zhao (renyuneyun) <renyuneyun@gmail.com>
Diffstat (limited to 'term-utils/script.c')
-rw-r--r--term-utils/script.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/term-utils/script.c b/term-utils/script.c
index 86f92c226..19ecddc93 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -70,6 +70,7 @@
#include "ttyutils.h"
#include "all-io.h"
#include "monotonic.h"
+#include "timeutils.h"
#include "debug.h"
@@ -435,8 +436,10 @@ static void do_io(struct script_control *ctl)
if (!ctl->quiet && ctl->typescriptfp) {
- strftime(buf, sizeof buf, "%c\n", localtime(&tvec));
- fprintf(ctl->typescriptfp, _("Script started on %s"), buf);
+ strtime_iso(&tvec, ISO_8601_DATE | ISO_8601_TIME | ISO_8601_DOTUSEC |
+ ISO_8601_TIMEZONE | ISO_8601_SPACE,
+ buf, sizeof(buf));
+ fprintf(ctl->typescriptfp, _("Script started on %s\n"), buf);
}
gettime_monotonic(&ctl->oldtime);
@@ -509,8 +512,10 @@ static void do_io(struct script_control *ctl)
wait_for_child(ctl, 1);
if (!ctl->quiet && ctl->typescriptfp) {
tvec = script_time((time_t *)NULL);
- strftime(buf, sizeof buf, "%c\n", localtime(&tvec));
- fprintf(ctl->typescriptfp, _("\nScript done on %s"), buf);
+ strtime_iso(&tvec, ISO_8601_DATE | ISO_8601_TIME | ISO_8601_DOTUSEC |
+ ISO_8601_TIMEZONE | ISO_8601_SPACE,
+ buf, sizeof(buf));
+ fprintf(ctl->typescriptfp, _("\nScript done on %s\n"), buf);
}
done(ctl);
}