Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Multios redirection while keeping current descriptors, and exec

On Tue, May 10, 2022 at 11:21 AM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
> Is there a simpler way to additionally log stdout/stderr to a file, while keeping the existing one?

Your best bet for that may be to use something like the "script"
command, or see if your terminal emulator can keep a log.

There is a long-standing bug with using multios with a "naked exec"
... but that will be fixed as of the 5.9 release, at which point
you'll be able to do e.g.:

exec 2>/tmp/err 2>/dev/tty

The drawback to this is that the background process that manages the
two outputs is not synchronized with ZLE, so you may not see the full
output as soon as you expect and/or the next prompt may be mixed into
the output.  The prompts themselves don't go to stdout or stderr,

You can garble this a bit less by setting up something with "zle -F"
to watch for text appearing in the log file, but you have to do so
carefully to avoid deadlock if the volume of output exceeds the OS's
internal I/O buffer space.

Messages sorted by: Reverse Date, Date, Thread, Author