]> git.ipfire.org Git - thirdparty/curl.git/commit
tool: improve --stderr handling
authorJay Satiro <raysatiro@yahoo.com>
Sat, 4 Mar 2023 09:07:24 +0000 (04:07 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Sun, 12 Mar 2023 05:58:40 +0000 (00:58 -0500)
commit2f17a9b654121dd1ecf4fc043c6d08a9da3522db
tree68a3c82a5a25e75df257be506196b1803c0559c2
parent395b9175b7422d699fa93643973295c106cdf147
tool: improve --stderr handling

- freopen stderr with the user-specified file (--stderr file) instead of
  using a separate 'errors' stream.

- In tool_setup.h override stdio.h's stderr macro as global variable
  tool_stderr.

Both freopen and overriding the stderr macro are necessary because if
the user-specified filename is "-" then stdout is assigned to
tool_stderr and no freopen takes place. See the PR for more information.

Ref: https://github.com/curl/curl/issues/10491

Closes https://github.com/curl/curl/pull/10673
14 files changed:
src/Makefile.inc
src/tool_cb_dbg.c
src/tool_cb_prg.c
src/tool_cfgable.h
src/tool_formparse.c
src/tool_getparam.c
src/tool_main.c
src/tool_msgs.c
src/tool_operate.c
src/tool_progress.c
src/tool_setup.h
src/tool_stderr.c [new file with mode: 0644]
src/tool_stderr.h [new file with mode: 0644]
src/tool_writeout.c