.Op Fl e
.Op Fl f
.Op Fl q
-.Op Fl t
+.Op Fl t[=FILE]
.Op Fl V
.Op Fl h
.Op Ar file
supervise real-time what is being done using `cat foo'.
.It Fl q, Fl Fl quiet
Be quiet.
-.It Fl t, Fl Fl timing
+.It Fl t, Fl Fl timing[=FILE]
Output timing data to standard error. This data contains two fields,
separated by a space. The first field indicates how much time elapsed since
the previous output. The second field indicates how many characters were
output this time. This information can be used to replay typescripts with
realistic typing and output delays.
+
+The timing option is able to take file path as an argument. The
+file is used as output detination instead of standard error when
+it is supplied.
.It Fl V, Fl Fl version
Output version information and exit.
.It Fl h, Fl Fl help
void getmaster(void);
void getslave(void);
void doinput(void);
-void dooutput(void);
+void dooutput(FILE *timingfd);
void doshell(void);
char *shell;
" -r, --return return exit code of the child process\n"
" -f, --flush run flush after each write\n"
" -q, --quiet be quiet\n"
- " -t, --timing output timing data to stderr\n"
+ " -t, --timing=FILE output timing data to stderr, or to file\n"
" -V, --version output version information and exit\n"
" -h, --help display this help and exit\n\n"));
struct sigaction sa;
extern int optind;
int ch;
+ FILE *timingfd = stderr;
static const struct option longopts[] = {
{ "append", no_argument, 0, 'a' },
{ "return", no_argument, 0, 'e' },
{ "flush", no_argument, 0, 'f' },
{ "quiet", no_argument, 0, 'q' },
- { "timing", no_argument, 0, 't' },
+ { "timing", optional_argument, 0, 't' },
{ "version", no_argument, 0, 'V' },
{ "help", no_argument, 0, 'h' },
{ NULL, 0, 0, 0 }
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while ((ch = getopt_long(argc, argv, "ac:efqtVh", longopts, NULL)) != -1)
+ while ((ch = getopt_long(argc, argv, "ac:efqt::Vh", longopts, NULL)) != -1)
switch((char)ch) {
case 'a':
aflg++;
qflg++;
break;
case 't':
+ if (optarg)
+ if ((timingfd = fopen(optarg, "w")) == NULL)
+ err(EXIT_FAILURE, _("cannot open timing file %s"), optarg);
tflg++;
break;
case 'V':
fail();
}
if (child)
- dooutput();
+ dooutput(timingfd);
else
doshell();
} else {
}
doinput();
+ fclose(timingfd);
return EXIT_SUCCESS;
}
}
void
-dooutput() {
+dooutput(FILE *timingfd) {
register ssize_t cc;
time_t tvec;
char obuf[BUFSIZ];
break;
if (tflg) {
newtime = tv.tv_sec + (double) tv.tv_usec / 1000000;
- fprintf(stderr, "%f %zd\n", newtime - oldtime, cc);
+ fprintf(timingfd, "%f %zd\n", newtime - oldtime, cc);
oldtime = newtime;
}
wrt = write(1, obuf, cc);