zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: <zsh-users@zsh.org>
Subject: Re: exec - interactive vs non-interactive shell
Date: Thu, 2 Jun 2011 09:59:26 +0100	[thread overview]
Message-ID: <op.vwfxxconnba3tw@pwspc01.europe.root.pri> (raw)
In-Reply-To: <4DE6B72B.6050806@gmail.com>

On Wed, 01 Jun 2011 23:03:23 +0100, Radoulov, Dimitre  
<cichomitiko@gmail.com> wrote:
> On 01/06/2011 22:42, Peter Stephenson wrote:
>> On Wed, 01 Jun 2011 21:55:04 +0200
>> "Radoulov, Dimitre"<cichomitiko@gmail.com>  wrote:
>>> zsh-4.3.11[t]% cat a_script
>>> exec cat
>>> ok
>>> zsh-4.3.11[t]%
>>>
>>>
>>> zsh-4.3.11[t]% zsh<   a_script
>>> ok
>> So cat has taken over stdin, as expected.
>>
> ash, dash and bash, for example, behave differently (ksh and variants  
> seem to behave like zsh).
> Do you know if this behavior is defined by the POSIX standard?

I suppose this is down to the behaviour of exec.  I didn't see anything
in the standard about what it should do with stdin when the current
shell was replaced with no additional redirection.

I think what's happened is probably that the shells that don't show
you anything have read ahead, so you still keep stdin from the same
place, but you don't necessarily get the very next line.  I suspect
this behaviour isn't defined.  (If that's right, then zsh's and ksh's
behaviour is the philosophically correct one, but there are
extenuating circumstances for the others.)

> If the shell is interactive, there's no script name nor explicit input  
> redirection (<) ,
> command and standard input come from the same channel too (the terminal),
> or I'm missing something?

You're not fundamentally missing anything, no, I deliberately glossed
over the way the shell opens the terminal.  It is based on stdin,
but in practice the shell duplicates the file descriptor and does
its terminal processing on a hidden one (i.e. greater than 9).

pws



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


  reply	other threads:[~2011-06-02  8:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-01 19:55 Fwd: " Radoulov, Dimitre
2011-06-01 20:42 ` Peter Stephenson
2011-06-01 22:03   ` Radoulov, Dimitre
2011-06-02  8:59     ` Peter Stephenson [this message]
2011-06-02  9:37       ` Radoulov, Dimitre

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=op.vwfxxconnba3tw@pwspc01.europe.root.pri \
    --to=pws@csr.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).