zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: multios and unnecessary processes
Date: Sun, 9 Jan 2005 20:32:18 +0000	[thread overview]
Message-ID: <1050109203218.ZM22780@candle.brasslantern.com> (raw)
In-Reply-To: <20050109164753.GA4246@sc>

On Jan 9,  4:47pm, Stephane Chazelas wrote:
} Subject: multios and unnecessary processes
}
} zsh -c 'lsof -ag $$ -d0-2,10-15 >&2 >&- >&2'
} 
} and 
} 
} zsh -c 'lsof -ag $$ -d0-2,10-15 >&2'
} 
} To work the same.

Interesting.  For me, they *do* work the same *if* the command is run
from the shell prompt rather than from "zsh -c".  In fact, I can only
reproduce your results if I use a non-interactive shell.  If I put those
two commands in files and execute the files with "zsh -if" I get (in
both cases):

OMMAND   PID  PGRP     USER   FD   TYPE DEVICE SIZE   NODE NAME
zsh     22683 22683 schaefer    0u   CHR  136,8          10 /dev/pts/8
zsh     22683 22683 schaefer    1u   CHR  136,8          10 /dev/pts/8
zsh     22683 22683 schaefer    2u   CHR  136,8          10 /dev/pts/8
zsh     22683 22683 schaefer   10r   REG    3,1   36 159782 /tmp/lsof1
zsh     22683 22683 schaefer   11u   CHR  136,8          10 /dev/pts/8

But if I leave off the -i I get the extra pipe descriptors in the first
case.  I don't know offhand why multios would behave differently when
the shell is interactive.

} I came accross this while trying to make some code independant
} of the multios setting (hence the >&- to cancel the teed
} redirection).

I'm a little puzzled by that statement, because in your second example
there is no teed redirection.  It's only the doubled >&2 that creates
a teed redirection in the first place.

The right way to write multios-independent code is to wrap things in
curly braces, e.g.:  { lsof -ag $$ -d0-2,10-15 >&2 } >&2
 
} I'm not too sure it's a good idea to make multios the default.

If I had been in Paul Falstad's place 15 years or so ago, I'd have
thought about making the default value of multios follow the the initial
value of interactive; that is, having it on for interactive shells
unless explicitly turned off, and the reverse for non-interactive
shells.  Maybe he did think about it, but that's not what he decided.


  reply	other threads:[~2005-01-09 20:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-09 16:47 Stephane Chazelas
2005-01-09 20:32 ` Bart Schaefer [this message]
2005-01-10  9:49   ` Stephane Chazelas
2005-01-10 16:53     ` Bart Schaefer
2005-01-10 17:11       ` Stephane Chazelas
2005-01-10 19:20         ` Bart Schaefer
2005-01-10 19:48           ` Peter Stephenson
2005-01-11  9:07           ` Stephane Chazelas

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=1050109203218.ZM22780@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.dk \
    /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).