diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-11-12 14:19:29 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-11-14 08:35:40 +0100 |
commit | f82bbe01c8835b8788c69f05362bb789766473cd (patch) | |
tree | e5c8bd5b8b10e24c350d0cfa830875f53cbc31ca /src | |
parent | f682156a4fc6c43fb38db4abda49b9a1bc1ed368 (diff) | |
download | curl-f82bbe01c8835b8788c69f05362bb789766473cd.tar.gz |
curl: add --fail-early
Exit with an error on the first transfer error instead of continuing to
do the rest of the URLs.
Discussion: https://curl.haxx.se/mail/archive-2016-11/0038.html
Diffstat (limited to 'src')
-rw-r--r-- | src/tool_cfgable.h | 2 | ||||
-rw-r--r-- | src/tool_getparam.c | 11 | ||||
-rw-r--r-- | src/tool_operate.c | 4 |
3 files changed, 12 insertions, 5 deletions
diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h index 9f4dbba8c..e72fab11b 100644 --- a/src/tool_cfgable.h +++ b/src/tool_cfgable.h @@ -239,7 +239,7 @@ struct GlobalConfig { bool tracetime; /* include timestamp? */ int progressmode; /* CURL_PROGRESS_BAR / CURL_PROGRESS_STATS */ char *libcurl; /* Output libcurl code to this file name */ - + bool fail_early; /* exit on first transfer error */ struct OperationConfig *first; struct OperationConfig *current; struct OperationConfig *last; /* Always last in the struct */ diff --git a/src/tool_getparam.c b/src/tool_getparam.c index d1888a2ab..1f89fbc00 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -231,6 +231,7 @@ static const struct LongShort aliases[]= { {"Es", "ssl-no-revoke", FALSE}, {"Et", "tcp-fastopen", FALSE}, {"f", "fail", FALSE}, + {"fa", "fail-early", FALSE}, {"F", "form", TRUE}, {"Fs", "form-string", TRUE}, {"g", "globoff", FALSE}, @@ -1438,8 +1439,14 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ } break; case 'f': - /* fail hard on errors */ - config->failonerror = toggle; + switch(subletter) { + case 'a': /* --fail-early */ + global->fail_early = toggle; + break; + default: + /* fail hard on errors */ + config->failonerror = toggle; + } break; case 'F': /* "form data" simulation, this is a little advanced so lets do our best diff --git a/src/tool_operate.c b/src/tool_operate.c index d467b0df5..c44f2141c 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -1805,9 +1805,9 @@ static CURLcode operate_do(struct GlobalConfig *global, urlnode->flags = 0; /* - ** Bail out upon critical errors + ** Bail out upon critical errors or --fail-early */ - if(is_fatal_error(result)) + if(is_fatal_error(result) || (result && global->fail_early)) goto quit_curl; } /* for-loop through all URLs */ |