]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
script: add option --log-out
authorKarel Zak <kzak@redhat.com>
Fri, 12 Apr 2019 10:13:08 +0000 (12:13 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 8 Oct 2019 11:11:53 +0000 (13:11 +0200)
Let's make script(1) command line more explicit about typescript file.

Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/script.1
term-utils/script.c

index 02ca31373acaef76d48c6644c01e77ab4e90f97a..3ae8909a66818df4d1f28b571dfac6027b47c305 100644 (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
index 28e8de36eb569d44d4b42fec8205c98040fb3b4e..bef5557424bcab635ff82b8ff383a55803716e9a 100644 (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);