aboutsummaryrefslogtreecommitdiff
path: root/util-linux/script.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-07 01:53:17 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-07 01:53:17 +0200
commitdd55d5d53c394edb65d392f77087049540568997 (patch)
tree1a34bd794d90b82fae295314ee745836eecb8a54 /util-linux/script.c
parent7b8372b81926ef6aa8d91945a95261bbb93d0b9e (diff)
downloadbusybox-w32-dd55d5d53c394edb65d392f77087049540568997.tar.gz
busybox-w32-dd55d5d53c394edb65d392f77087049540568997.tar.bz2
busybox-w32-dd55d5d53c394edb65d392f77087049540568997.zip
script: make -t independent of scriptreplay
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/script.c')
-rw-r--r--util-linux/script.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/util-linux/script.c b/util-linux/script.c
index 9eebb51a4..6e8094312 100644
--- a/util-linux/script.c
+++ b/util-linux/script.c
@@ -21,15 +21,23 @@
21//kbuild:lib-$(CONFIG_SCRIPT) += script.o 21//kbuild:lib-$(CONFIG_SCRIPT) += script.o
22 22
23//usage:#define script_trivial_usage 23//usage:#define script_trivial_usage
24//usage: "[-afq" IF_SCRIPTREPLAY("t") "] [-c PROG] [OUTFILE]" 24//usage: "[-afqt] [-c PROG] [OUTFILE]"
25//usage:#define script_full_usage "\n\n" 25//usage:#define script_full_usage "\n\n"
26//usage: " -a Append output" 26//usage: " -a Append output"
27//usage: "\n -c PROG Run PROG, not shell" 27//usage: "\n -c PROG Run PROG, not shell"
28//usage: "\n -f Flush output after each write" 28//usage: "\n -f Flush output after each write"
29//usage: "\n -q Quiet" 29//usage: "\n -q Quiet"
30//usage: IF_SCRIPTREPLAY(
31//usage: "\n -t Send timing to stderr" 30//usage: "\n -t Send timing to stderr"
32//usage: ) 31
32//util-linux-2.28:
33//-t[FILE]
34//-e: return exit code of the child
35
36//FYI (reported as bbox bug #2749):
37// > script -q -c 'echo -e -n "1\n2\n3\n"' /dev/null </dev/null >123.txt
38// > The output file on full-blown ubuntu system contains 6 bytes.
39// > Output on Busybox system (arm-linux) contains extra '\r' byte in each line.
40//however, in my test, "script" from util-linux-2.28 seems to also add '\r' bytes.
33 41
34#include "libbb.h" 42#include "libbb.h"
35#include "common_bufsiz.h" 43#include "common_bufsiz.h"
@@ -64,14 +72,14 @@ int script_main(int argc UNUSED_PARAM, char **argv)
64 "command\0" Required_argument "c" 72 "command\0" Required_argument "c"
65 "flush\0" No_argument "f" 73 "flush\0" No_argument "f"
66 "quiet\0" No_argument "q" 74 "quiet\0" No_argument "q"
67 IF_SCRIPTREPLAY("timing\0" No_argument "t") 75 "timing\0" No_argument "t"
68 ; 76 ;
69 77
70 applet_long_options = getopt_longopts; 78 applet_long_options = getopt_longopts;
71#endif 79#endif
72 80
73 opt_complementary = "?1"; /* max one arg */ 81 opt_complementary = "?1"; /* max one arg */
74 opt = getopt32(argv, "ac:fq" IF_SCRIPTREPLAY("t") , &shell_arg); 82 opt = getopt32(argv, "ac:fqt", &shell_arg);
75 //argc -= optind; 83 //argc -= optind;
76 argv += optind; 84 argv += optind;
77 if (argv[0]) { 85 if (argv[0]) {
@@ -120,7 +128,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
120 /* parent */ 128 /* parent */
121 struct pollfd pfd[2]; 129 struct pollfd pfd[2];
122 int outfd, count, loop; 130 int outfd, count, loop;
123 double oldtime = ENABLE_SCRIPTREPLAY ? time(NULL) : 0; 131 double oldtime = time(NULL);
124 smallint fd_count = 2; 132 smallint fd_count = 2;
125#define buf bb_common_bufsiz1 133#define buf bb_common_bufsiz1
126 setup_common_bufsiz(); 134 setup_common_bufsiz();
@@ -151,7 +159,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
151 goto restore; 159 goto restore;
152 } 160 }
153 if (count > 0) { 161 if (count > 0) {
154 if (ENABLE_SCRIPTREPLAY && (opt & OPT_t)) { 162 if (opt & OPT_t) {
155 struct timeval tv; 163 struct timeval tv;
156 double newtime; 164 double newtime;
157 165