* [PATCH] script: abort if unused arguments are given
@ 2022-11-18 13:23 Chris Hofstaedtler
2022-11-21 10:09 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Chris Hofstaedtler @ 2022-11-18 13:23 UTC (permalink / raw)
To: util-linux; +Cc: наб
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 <zeha@debian.org>
Reported-by: наб <nabijaczleweli@nabijaczleweli.xyz>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1016193
---
term-utils/script.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/term-utils/script.c b/term-utils/script.c
index 516a6cf93..c4b8e3337 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -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),
--
2.38.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] script: abort if unused arguments are given
2022-11-18 13:23 [PATCH] script: abort if unused arguments are given Chris Hofstaedtler
@ 2022-11-21 10:09 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2022-11-21 10:09 UTC (permalink / raw)
To: Chris Hofstaedtler; +Cc: util-linux, наб
On Fri, Nov 18, 2022 at 01:23:37PM +0000, Chris Hofstaedtler wrote:
> term-utils/script.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
Applied.
> + 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
>
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-21 10:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-18 13:23 [PATCH] script: abort if unused arguments are given Chris Hofstaedtler
2022-11-21 10:09 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).