zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-users@zsh.org
Subject: Re: Odd behavior using MULTIOS
Date: Wed, 11 Nov 2020 16:42:06 +0000 (GMT)	[thread overview]
Message-ID: <774738440.1331269.1605112926240@mail2.virginmedia.com> (raw)
In-Reply-To: <02c5fda1-c1ab-d0a0-9350-a5b122cd1394@zentaur.org>


> On 11 November 2020 at 16:25 Clinton Bunch <cdb_zsh@zentaur.org> 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


  reply	other threads:[~2020-11-11 16:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11 16:25 Clinton Bunch
2020-11-11 16:42 ` Peter Stephenson [this message]
2020-11-11 17:11   ` Clinton Bunch
2020-11-11 17:25     ` Peter Stephenson
2020-11-11 17:36       ` Clinton Bunch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=774738440.1331269.1605112926240@mail2.virginmedia.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).