Awful way to solve your problem:
exec 3>&2
trap 'exec 2>>/path/to/your_file' DEBUG
PROMPT_COMMAND='exec 2>&3'
exec 3>&2
: we first copy fd 2 to the new fd (here fd 3)trap 'exec 2>/dev/null' DEBUG
: ( extdebug
, ), DEBUG
: stderr
/path/to/your_file
(, ).- Bash
PROMPT_COMMAND
: fd2 fd3 ( fd3 - fd2, ). , .
, .