script: add option --log-out

Let's make script(1) command line more explicit about typescript file.

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2019-04-12 12:13:08 +02:00
parent c64963f87c
commit ddbdb79256
2 changed files with 17 additions and 6 deletions

View File

@ -47,7 +47,7 @@ assignment, as the typescript file can be printed out later with
.PP
If the argument
.I file
is given,
or option \fB\-\-log\-out\fR \fIfile\fR is given,
.B script
saves the dialogue in this
.IR file .
@ -87,6 +87,10 @@ being done using `cat foo'.
Allow the default output destination, i.e. the typescript file, to be a hard
or symbolic link. The command will follow a symbolic link.
.TP
\fB\-O\fR, \fB\-\-log\-out\fR \fIfile\fR
Log output to the \fIfile\fR. The default is to log the file with name 'typescript'
if the option is not given.
.TP
\fB\-o\fR, \fB\-\-output-limit\fR \fIsize\fR
Limit the size of the typescript and timing files to
.I size

View File

@ -188,6 +188,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_("Make a typescript of a terminal session.\n"), out);
fputs(USAGE_OPTIONS, out);
fputs(_(" -O, --log-out <file> log stdout to file (default)\n"), out);
fputs(_(" -a, --append append the output\n"), out);
fputs(_(" -c, --command <command> run command rather than interactive shell\n"), out);
fputs(_(" -e, --return return exit code of the child process\n"), out);
@ -895,6 +896,7 @@ int main(int argc, char **argv)
{"return", no_argument, NULL, 'e'},
{"flush", no_argument, NULL, 'f'},
{"force", no_argument, NULL, FORCE_OPTION,},
{"log-out", required_argument, NULL, 'O'},
{"output-limit", required_argument, NULL, 'o'},
{"quiet", no_argument, NULL, 'q'},
{"timing", optional_argument, NULL, 't'},
@ -918,7 +920,7 @@ int main(int argc, char **argv)
script_init_debug();
while ((ch = getopt_long(argc, argv, "ac:efo:qt::Vh", longopts, NULL)) != -1)
while ((ch = getopt_long(argc, argv, "ac:efO:o:qt::Vh", longopts, NULL)) != -1)
switch (ch) {
case 'a':
ctl.append = 1;
@ -935,6 +937,9 @@ int main(int argc, char **argv)
case FORCE_OPTION:
ctl.force = 1;
break;
case 'O':
typescript = optarg;
break;
case 'o':
ctl.maxsz = strtosize_or_err(optarg, _("failed to parse output limit size"));
break;
@ -961,10 +966,12 @@ int main(int argc, char **argv)
argc -= optind;
argv += optind;
if (argc > 0)
typescript = argv[0];
else
die_if_link(&ctl, DEFAULT_TYPESCRIPT_FILENAME);
if (!typescript) {
if (argc > 0)
typescript = argv[0];
else
die_if_link(&ctl, DEFAULT_TYPESCRIPT_FILENAME);
}
/* associate stdout with typescript file */
log_associate(&ctl, &ctl.out, typescript, SCRIPT_FMT_RAW);