summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2022-01-02 17:42:04 +0100
committerDaniel Stenberg <daniel@haxx.se>2022-01-03 15:55:38 +0100
commitee2ca5826bea7c061f3525cfc6b542c35d41fa50 (patch)
tree2c8d62735c81bea2a278c77d35373f6a912db6f3
parentc07aca3baad7c08f25d6b8d2ea6fb30ceaee50fc (diff)
downloadcurl-ee2ca5826bea7c061f3525cfc6b542c35d41fa50.tar.gz
tool_operate: warn if too many output arguments were found
More output instructions than URLs is likely a user error. Add test case 371 to verify Closes #8210
-rw-r--r--src/tool_operate.c8
-rw-r--r--tests/data/Makefile.inc4
-rw-r--r--tests/data/test37156
-rwxr-xr-xtests/runtests.pl8
4 files changed, 72 insertions, 4 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 44f01e94e..fe2c43b55 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -735,6 +735,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
}
while(config->state.urlnode) {
+ static bool warn_more_options = FALSE;
char *infiles; /* might be a glob pattern */
struct URLGlob *inglob = state->inglob;
urlnode = config->state.urlnode;
@@ -749,6 +750,11 @@ static CURLcode single_transfer(struct GlobalConfig *global,
urlnode->flags = 0;
config->state.urlnode = urlnode->next;
state->up = 0;
+ if(!warn_more_options) {
+ /* only show this once */
+ warnf(config->global, "Got more output options than URLs\n");
+ warn_more_options = TRUE;
+ }
continue; /* next URL please */
}
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index 75f6397ea..dad423258 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -61,7 +61,7 @@ test334 test335 test336 test337 test338 test339 test340 test341 test342 \
test343 test344 test345 test346 test347 test348 test349 test350 test351 \
test352 test353 test354 test355 test356 test357 test358 test359 test360 \
test361 test362 test363 test364 test365 test366 test367 test368 test369 \
-test370 \
+test370 test371 \
\
test392 test393 test394 test395 test396 test397 \
\
diff --git a/tests/data/test371 b/tests/data/test371
new file mode 100644
index 000000000..3a44db575
--- /dev/null
+++ b/tests/data/test371
@@ -0,0 +1,56 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data nocheck="yes">
+HTTP/1.1 200 OK
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
+ETag: "21025-dc7-39462498"
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Funny-head: yesyes
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+using more -o than URLs in the command line
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER -o log/dump -o log/dump2 --no-progress-meter
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+GET /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+</protocol>
+<stderr mode="text">
+Warning: Got more output options than URLs
+</stderr>
+</verify>
+</testcase>
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 046f8d356..7f3b20c14 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -6,7 +6,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -4364,6 +4364,12 @@ sub singletest {
# get the mode attribute
my $filemode=$hash{'mode'};
+ if($filemode && ($filemode eq "text") && $has_hyper) {
+ # text mode check in hyper-mode. Sometimes necessary if the stderr
+ # data *looks* like HTTP and thus has gotten CRLF newlines
+ # mistakenly
+ map s/\r\n/\n/g, @validstderr;
+ }
if($filemode && ($filemode eq "text") && $has_textaware) {
# text mode when running on windows: fix line endings
map s/\r\n/\n/g, @validstderr;