diff options
author | Jay Satiro <raysatiro@yahoo.com> | 2023-02-20 14:16:41 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2023-02-23 10:05:13 +0100 |
commit | d9b7f6e750ad415ec384d88970bd718b163e1c1f (patch) | |
tree | dd55e814c733915017d2a4f67ac6924b171e4784 /src | |
parent | 80b7f05bafdc69ce21447f9c613ef91040504a4c (diff) | |
download | curl-d9b7f6e750ad415ec384d88970bd718b163e1c1f.tar.gz |
curl: make -w's %{stderr} use the file set with --stderr
Reported-by: u20221022 on github
Fixes #10491
Closes #10569
Diffstat (limited to 'src')
-rw-r--r-- | src/tool_operate.c | 2 | ||||
-rw-r--r-- | src/tool_writeout.c | 8 | ||||
-rw-r--r-- | src/tool_writeout.h | 2 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c index ba089b3bf..804d981d9 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -661,7 +661,7 @@ static CURLcode post_per_transfer(struct GlobalConfig *global, /* Write the --write-out data before cleanup but after result is final */ if(config->writeout) - ourWriteOut(config->writeout, per, result); + ourWriteOut(config, per, result); /* Close function-local opened file descriptors */ if(per->heads.fopened && per->heads.stream) diff --git a/src/tool_writeout.c b/src/tool_writeout.c index 5246db2cf..d93de829a 100644 --- a/src/tool_writeout.c +++ b/src/tool_writeout.c @@ -376,15 +376,19 @@ static int writeOffset(FILE *stream, const struct writeoutvar *wovar, return 1; /* return 1 if anything was written */ } -void ourWriteOut(const char *writeinfo, struct per_transfer *per, +void ourWriteOut(struct OperationConfig *config, struct per_transfer *per, CURLcode per_result) { FILE *stream = stdout; + const char *writeinfo = config->writeout; const char *ptr = writeinfo; bool done = FALSE; struct curl_certinfo *certinfo; CURLcode res = curl_easy_getinfo(per->curl, CURLINFO_CERTINFO, &certinfo); + if(!writeinfo) + return; + if(!res && certinfo) per->certinfo = certinfo; @@ -423,7 +427,7 @@ void ourWriteOut(const char *writeinfo, struct per_transfer *per, stream = stdout; break; case VAR_STDERR: - stream = stderr; + stream = config->global->errors; break; case VAR_JSON: ourWriteOutJSON(stream, variables, per, per_result); diff --git a/src/tool_writeout.h b/src/tool_writeout.h index 0c07f222b..fac7bdd19 100644 --- a/src/tool_writeout.h +++ b/src/tool_writeout.h @@ -84,7 +84,7 @@ struct writeoutvar { bool use_json); }; -void ourWriteOut(const char *writeinfo, struct per_transfer *per, +void ourWriteOut(struct OperationConfig *config, struct per_transfer *per, CURLcode per_result); #endif /* HEADER_CURL_TOOL_WRITEOUT_H */ |