On 11 November 2020 at 16:25 Clinton Bunch <cdb_zsh@xxxxxxxxxxx> wrote:
Is this the expected behavior?
setopt MULTIOS
{
print -u3 "Testing"
print "Second Testing"
} 3>&1 3>/tmp/test
% zsh test.zsh
Second Testing
Testing
You mean the ordering? Yes, as documented "the shell opens the file descriptor as a pipe
to a process that copies its input to all the specified outputs". So this isn't
synchronous within the current shell and you can't rely on ordering. You'll note
there's nothing there to determine whether the downstream pipe component performs
a write to the terminal before the main shell does --- think of it a bit like
{ print Testing; print "Second Testing" >/dev/tty } | tee /dev/tty /tmp/test
--- although I'm not guaranteeing they're identical and clearly there's room
for lots of things in the two processes to affect the ordering.
pws