#436·xh

Allow to redirect parts of output to STDERR

Author: andrew-grechkinCreated Dec 5, 2025Updated Dec 6, 2025

For debug purpose, especially when using xh in a pipeline or result needs processing, it's quite nice to be able to collect headers (and request body too).

Currently this is not possible because all output assumes STDOUT.

One of the solutions would be to give ability to control (--stderr-print or --print-stderr) where separate parts are printed like:

bash
if res=$(xhs jsonplaceholder.typicode.com/users --stderr-print=HBh 2>debug.out); then
    : # do something with res if everything is OK
else
   errno="$?"
   echo 'error occurred:' >&2
   cat debug.out >&2
   echo "$res" >&2
   exit "$errno"
fi