From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25951 invoked by alias); 2 Jun 2011 09:37:24 -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: 16080 Received: (qmail 9352 invoked from network); 2 Jun 2011 09:37:23 -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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 74.125.82.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=+M61ldvc9z3Hpc2bmlxeP2gX2qcFf4nMc/dYy6ItYks=; b=QvK9k2Sm7p6kDNZ4Wirl9PXEyS/V/3n49Lr2D68CjgMKRYlB632d4boqJBGIrtTGnX xJ/VYZroi/D4Ro47sl2rrVF9CuIfsfhP6xPq+BD/j7W2GaJcp8fzUHIFhtg8zNc1W4Se 8CWT1M20nOjLhP6f6XUYPRmpTn9l6jsiqPXNc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=BbUyE/R4D4p3kGlSAfdjq8XE9DoGuMeK7FJ+47+ad85I9uCTnmwM3waCe1zoZ/h536 NbOg3dNJDGqiN1UVmLTuoPvLOpBRJfjyhcRIjhqmeUBiqU2X2MM4gXqys502sCfKbbo7 RSNISmEZphg7CviTvKWXKRLyKSA0qfGEVrgyQ= Message-ID: <4DE759C7.6070004@gmail.com> Date: Thu, 02 Jun 2011 11:37:11 +0200 From: "Radoulov, Dimitre" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: zsh-users@zsh.org Subject: Re: exec - interactive vs non-interactive shell References: <4DE69918.4040205@gmail.com> <20110601214240.6fde31de@pws-pc.ntlworld.com> <4DE6B72B.6050806@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit On 02/06/2011 10:59, Peter Stephenson wrote: > 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). > Thanks again! Best regards Dimitre