script: make -t independent of scriptreplay
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 6 Aug 2017 23:53:17 +0000 (01:53 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 6 Aug 2017 23:53:17 +0000 (01:53 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
NOFORK_NOEXEC.lst
util-linux/script.c
util-linux/scriptreplay.c

index ac04f75da9c5c04b4a554f020bbf0bbc8e0f6757..21f09728d86867626cb970d34f4416aa38870d7c 100644 (file)
@@ -299,8 +299,8 @@ runlevel - noexec. can be nofork if "endutxent()" is called unconditionally, but
 runsv - daemon
 runsvdir - daemon
 rx - runner
-script
-scriptreplay
+script - longterm: pumps script output from slave pty
+scriptreplay - longterm: plays back "script" saved output, sleeping as necessary.
 sed - runner
 sendmail - runner
 seq - noexec. runner
index 9eebb51a44bbca77b2f1ebfce87251f3a8021af2..6e80943128e3c9300572fcfdcc35a79d49e04679 100644 (file)
 //kbuild:lib-$(CONFIG_SCRIPT) += script.o
 
 //usage:#define script_trivial_usage
-//usage:       "[-afq" IF_SCRIPTREPLAY("t") "] [-c PROG] [OUTFILE]"
+//usage:       "[-afqt] [-c PROG] [OUTFILE]"
 //usage:#define script_full_usage "\n\n"
 //usage:       "       -a      Append output"
 //usage:     "\n       -c PROG Run PROG, not shell"
 //usage:     "\n       -f      Flush output after each write"
 //usage:     "\n       -q      Quiet"
-//usage:       IF_SCRIPTREPLAY(
 //usage:     "\n       -t      Send timing to stderr"
-//usage:       )
+
+//util-linux-2.28:
+//-t[FILE]
+//-e: return exit code of the child
+
+//FYI (reported as bbox bug #2749):
+// > script -q -c 'echo -e -n "1\n2\n3\n"' /dev/null </dev/null >123.txt
+// > The output file on full-blown ubuntu system contains 6 bytes.
+// > Output on Busybox system (arm-linux) contains extra '\r' byte in each line.
+//however, in my test, "script" from util-linux-2.28 seems to also add '\r' bytes.
 
 #include "libbb.h"
 #include "common_bufsiz.h"
@@ -64,14 +72,14 @@ int script_main(int argc UNUSED_PARAM, char **argv)
                "command\0" Required_argument "c"
                "flush\0"   No_argument       "f"
                "quiet\0"   No_argument       "q"
-               IF_SCRIPTREPLAY("timing\0" No_argument "t")
+               "timing\0"  No_argument       "t"
                ;
 
        applet_long_options = getopt_longopts;
 #endif
 
        opt_complementary = "?1"; /* max one arg */
-       opt = getopt32(argv, "ac:fq" IF_SCRIPTREPLAY("t") , &shell_arg);
+       opt = getopt32(argv, "ac:fqt", &shell_arg);
        //argc -= optind;
        argv += optind;
        if (argv[0]) {
@@ -120,7 +128,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
                /* parent */
                struct pollfd pfd[2];
                int outfd, count, loop;
-               double oldtime = ENABLE_SCRIPTREPLAY ? time(NULL) : 0;
+               double oldtime = time(NULL);
                smallint fd_count = 2;
 #define buf bb_common_bufsiz1
                setup_common_bufsiz();
@@ -151,7 +159,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
                                        goto restore;
                                }
                                if (count > 0) {
-                                       if (ENABLE_SCRIPTREPLAY && (opt & OPT_t)) {
+                                       if (opt & OPT_t) {
                                                struct timeval tv;
                                                double newtime;
 
index 7e98501036898e08a2bbcffa44d9dd16a16d89d0..e3083ab93ae91d701c8af03c9c0440e53ca80292 100644 (file)
@@ -5,7 +5,6 @@
  * pascal.bellard@ads-lu.com
  *
  * Licensed under GPLv2 or later, see file LICENSE in this source tree.
- *
  */
 //config:config SCRIPTREPLAY
 //config:      bool "scriptreplay (2.6 kb)"
@@ -19,7 +18,7 @@
 //kbuild:lib-$(CONFIG_SCRIPTREPLAY) += scriptreplay.o
 
 //usage:#define scriptreplay_trivial_usage
-//usage:       "timingfile [typescript [divisor]]"
+//usage:       "TIMINGFILE [TYPESCRIPT [DIVISOR]]"
 //usage:#define scriptreplay_full_usage "\n\n"
 //usage:       "Play back typescripts, using timing information"