aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-07 02:12:36 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-07 02:12:36 +0200
commit269b36a49a60a90ce59dd6209728ec97fd72077e (patch)
tree2db1d92779e732f5ced3afc10ec79744167df201
parentdd55d5d53c394edb65d392f77087049540568997 (diff)
downloadbusybox-w32-269b36a49a60a90ce59dd6209728ec97fd72077e.tar.gz
busybox-w32-269b36a49a60a90ce59dd6209728ec97fd72077e.tar.bz2
busybox-w32-269b36a49a60a90ce59dd6209728ec97fd72077e.zip
script: make -t[FILE] compatible with util-linux
function old new delta script_main 1056 1102 +46 packed_usage 31736 31765 +29 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 75/0) Total: 75 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/sed.c4
-rw-r--r--util-linux/script.c22
2 files changed, 17 insertions, 9 deletions
diff --git a/editors/sed.c b/editors/sed.c
index bec20040a..22580cf71 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -68,8 +68,8 @@
68//applet:IF_SED(APPLET(sed, BB_DIR_BIN, BB_SUID_DROP)) 68//applet:IF_SED(APPLET(sed, BB_DIR_BIN, BB_SUID_DROP))
69 69
70//usage:#define sed_trivial_usage 70//usage:#define sed_trivial_usage
71//usage: "[-inrE] [-f FILE]... [-e CMD]... [FILE]...\n" 71//usage: "[-i[SFX]] [-nrE] [-f FILE]... [-e CMD]... [FILE]...\n"
72//usage: "or: sed [-inrE] CMD [FILE]..." 72//usage: "or: sed [-i[SFX]] [-nrE] CMD [FILE]..."
73//usage:#define sed_full_usage "\n\n" 73//usage:#define sed_full_usage "\n\n"
74//usage: " -e CMD Add CMD to sed commands to be executed" 74//usage: " -e CMD Add CMD to sed commands to be executed"
75//usage: "\n -f FILE Add FILE contents to sed commands to be executed" 75//usage: "\n -f FILE Add FILE contents to sed commands to be executed"
diff --git a/util-linux/script.c b/util-linux/script.c
index 6e8094312..62a241762 100644
--- a/util-linux/script.c
+++ b/util-linux/script.c
@@ -21,16 +21,17 @@
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: "[-afqt] [-c PROG] [OUTFILE]" 24//usage: "[-afq] [-t[FILE]] [-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: "Default OUTFILE is 'typescript'"
27//usage: "\n"
28//usage: "\n -a Append output"
27//usage: "\n -c PROG Run PROG, not shell" 29//usage: "\n -c PROG Run PROG, not shell"
28//usage: "\n -f Flush output after each write" 30//usage: "\n -f Flush output after each write"
29//usage: "\n -q Quiet" 31//usage: "\n -q Quiet"
30//usage: "\n -t Send timing to stderr" 32//usage: "\n -t[FILE] Send timing to stderr or FILE"
31 33
32//util-linux-2.28: 34//util-linux-2.28:
33//-t[FILE]
34//-e: return exit code of the child 35//-e: return exit code of the child
35 36
36//FYI (reported as bbox bug #2749): 37//FYI (reported as bbox bug #2749):
@@ -54,6 +55,8 @@ int script_main(int argc UNUSED_PARAM, char **argv)
54 char pty_line[GETPTY_BUFSIZE]; 55 char pty_line[GETPTY_BUFSIZE];
55 struct termios tt, rtt; 56 struct termios tt, rtt;
56 struct winsize win; 57 struct winsize win;
58 FILE *timing_fp;
59 const char *str_t = NULL;
57 const char *fname = "typescript"; 60 const char *fname = "typescript";
58 const char *shell; 61 const char *shell;
59 char shell_opt[] = "-i"; 62 char shell_opt[] = "-i";
@@ -72,14 +75,14 @@ int script_main(int argc UNUSED_PARAM, char **argv)
72 "command\0" Required_argument "c" 75 "command\0" Required_argument "c"
73 "flush\0" No_argument "f" 76 "flush\0" No_argument "f"
74 "quiet\0" No_argument "q" 77 "quiet\0" No_argument "q"
75 "timing\0" No_argument "t" 78 "timing\0" Optional_argument "t"
76 ; 79 ;
77 80
78 applet_long_options = getopt_longopts; 81 applet_long_options = getopt_longopts;
79#endif 82#endif
80 83
81 opt_complementary = "?1"; /* max one arg */ 84 opt_complementary = "?1"; /* max one arg */
82 opt = getopt32(argv, "ac:fqt", &shell_arg); 85 opt = getopt32(argv, "ac:fqt::", &shell_arg, &str_t);
83 //argc -= optind; 86 //argc -= optind;
84 argv += optind; 87 argv += optind;
85 if (argv[0]) { 88 if (argv[0]) {
@@ -95,6 +98,10 @@ int script_main(int argc UNUSED_PARAM, char **argv)
95 if (!(opt & OPT_q)) { 98 if (!(opt & OPT_q)) {
96 printf("Script started, file is %s\n", fname); 99 printf("Script started, file is %s\n", fname);
97 } 100 }
101 timing_fp = stderr;
102 if (str_t) {
103 timing_fp = xfopen_for_write(str_t);
104 }
98 105
99 shell = get_shell_name(); 106 shell = get_shell_name();
100 107
@@ -130,6 +137,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
130 int outfd, count, loop; 137 int outfd, count, loop;
131 double oldtime = time(NULL); 138 double oldtime = time(NULL);
132 smallint fd_count = 2; 139 smallint fd_count = 2;
140
133#define buf bb_common_bufsiz1 141#define buf bb_common_bufsiz1
134 setup_common_bufsiz(); 142 setup_common_bufsiz();
135 143
@@ -165,7 +173,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
165 173
166 gettimeofday(&tv, NULL); 174 gettimeofday(&tv, NULL);
167 newtime = tv.tv_sec + (double) tv.tv_usec / 1000000; 175 newtime = tv.tv_sec + (double) tv.tv_usec / 1000000;
168 fprintf(stderr, "%f %u\n", newtime - oldtime, count); 176 fprintf(timing_fp, "%f %u\n", newtime - oldtime, count);
169 oldtime = newtime; 177 oldtime = newtime;
170 } 178 }
171 full_write(STDOUT_FILENO, buf, count); 179 full_write(STDOUT_FILENO, buf, count);