script: abort if unused arguments are given
PATCH 1/1 script: abort if unused arguments are given
scripts uses either a free-standing "file" argument, or the value passed as --log-out "file". Additional filenames are ignored. They are also ignored if --log-in "file" is given, as it turns off output logging by default (can still be overriden by adding --log-out). Avoid surprises when passing multiple filenames by writing usage message instead.
Signed-off-by Chris Hofstaedtler <[email protected]>
Reported-by наб <[email protected]>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1016193
--- term-utils/script.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
term-utils/script.c +10 -2
@@ -889,9 +889,11 @@ int main(int argc, char **argv)/* default if no --log-* specified */ if (!outfile && !infile) { -if (argc >0 ) +if (argc >0 ) { outfile = argv[0 ]; -else { + argc--; + argv++; + }else {die_if_link (&ctl,DEFAULT_TYPESCRIPT_FILENAME ); outfile =DEFAULT_TYPESCRIPT_FILENAME ; }
@@ -900,6 +902,12 @@ int main(int argc, char **argv)log_associate (&ctl, &ctl.out, outfile,SCRIPT_FMT_RAW ); } +if (argc >0 ) { +/* only one filename is accepted. if --log-out was given, +* freestanding filename is ignored */ +usage (); + } +if (timingfile) {/* the old SCRIPT_FMT_TIMING_SIMPLE should be used when * recoding output only (just for backward compatibility),
Signature · 1 line
2.38.1
Quoted 2 lines · Chris Hofstaedtler
term-utils/script.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
Applied.
term-utils/script.c int main(int argc, char **argv) · line 909
Quoted 5 lines
term-utils/script.c +5
-0+if (argc >0 ) { +/* only one filename is accepted. if --log-out was given, +* freestanding filename is ignored */ +usage (); + }
We do not use usage() in this case, but errtryhelp() to get
$ script aaa bbb
script: unexpected number of arguments
Try 'script --help' for more information.Fixed. Thanks.
Karel
Quoted 1 line
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com