]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fix the position of newline in the time output of 'script'
authorRui Zhao (renyuneyun) <renyuneyun@gmail.com>
Fri, 14 Apr 2017 16:43:41 +0000 (17:43 +0100)
committerRui Zhao (renyuneyun) <renyuneyun@gmail.com>
Fri, 14 Apr 2017 16:49:25 +0000 (17:49 +0100)
- move '\n' to fprintf
- use `timeutils/strtime_iso()` instead of `strtime()`

Signed-off-by: Rui Zhao (renyuneyun) <renyuneyun@gmail.com>
term-utils/script.c

index 86f92c2264e6645a6bdf6171b640dfe8295b78f7..19ecddc933e0530be74a7ae47d2c2785e95c5ad9 100644 (file)
@@ -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);
 }