From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3257 invoked by alias); 2 Jun 2011 08:59:37 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16078 Received: (qmail 24258 invoked from network); 2 Jun 2011 08:59:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Content-Type: text/plain; charset="iso-8859-15"; format=flowed; delsp=yes To: Subject: Re: exec - interactive vs non-interactive shell References: <4DE69918.4040205@gmail.com> <20110601214240.6fde31de@pws-pc.ntlworld.com> <4DE6B72B.6050806@gmail.com> Date: Thu, 2 Jun 2011 09:59:26 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Peter Stephenson Organization: Cambridge Silicon Radio Message-ID: In-Reply-To: <4DE6B72B.6050806@gmail.com> User-Agent: Opera Mail/11.11 (Win32) X-Originating-IP: [10.103.10.173] X-Scanned-By: MailControl A-10-80-00 (www.mailcontrol.com) on 10.71.0.126 On Wed, 01 Jun 2011 23:03:23 +0100, Radoulov, Dimitre wrote: > On 01/06/2011 22:42, Peter Stephenson wrote: >> On Wed, 01 Jun 2011 21:55:04 +0200 >> "Radoulov, Dimitre" 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