From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14411 invoked by alias); 1 Jun 2011 22:03:43 -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: 16072 Received: (qmail 11358 invoked from network); 1 Jun 2011 22:03:31 -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 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 74.125.82.43 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 :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=csKEnQhNXrdEH71EXAljlJXhhDiiI3mBzdIkC3m3er4=; b=KhBtKi4W8wOdkHO/QVz+1iuuumO5nK5hr5s4QpdcFI3YBhsrzcEyLlSxQWCghgHHhl S4YQGJZQdurNbz8bi6it0wQ7mXWfwtVESfAarbKLXFVRScFRYnu7RcQ3xOMc0Zc1iyPo 2U169gNX+Oqy9MI3yGSSgNvrrEJfqKJ4IKWek= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=quKIIRb/kBMZwhwHkeya7h0JLRo5bjX/epCClVQRJhLb5sz5YfBYx2jQLCjS0R7DU+ oairc813YevgNPZp6aDintnbsQTnz2MsSbVQjd6/EuNPoB0Wqinpu/WO2+PRuLevtPdU qzD3MT367d31+Cqc1j5JUjYnpPfpzfkh/20RM= Message-ID: <4DE6B72B.6050806@gmail.com> Date: Thu, 02 Jun 2011 00:03:23 +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: Peter Stephenson CC: zsh-users@zsh.org Subject: Re: exec - interactive vs non-interactive shell References: <4DE69918.4040205@gmail.com> <20110601214240.6fde31de@pws-pc.ntlworld.com> In-Reply-To: <20110601214240.6fde31de@pws-pc.ntlworld.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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. > Yes, 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? >> zsh-4.3.11[t]% zsh -i< a_script >> zsh-4.3.11[t]% >> >> >> No output with -i. > You're confusing the effects of "zsh -i a_script". The first one starts up zsh as an interactive shell, with a > line editor, but with standard input (not commands, which are > interactive) coming from a_script. You'll find that prompt on the line > after is inside the new interactive shell. Try typing at this point: > > read > print $REPLY > > You should see "exec ok". > > The rules for how zsh finds the commands and standard input are roughly: > > - Standard input is only redirected if you explicitly use a "<". > (So "zsh a_script" leaves stdin where it is and cat hangs waiting for > input.) It's independent of interaction with the terminal for reading > commands (though there's the more complicated issue of how the terminal > gets set up in the first place). > > - If there's a script name, use that for commands, regardless of whether > the shell is interactive or not. (So "zsh -i a_script" behaves > basically like without the -i, although you could have interactive shell > commands such as vared in the script.) > > - If there's no script name and the shell is interactive, use the > terminal for commands. > > - If there's no script name and the shell is not interactive, fall back > to reading commands from standard input. This is the only case (without > making special arrangements) where commands and standard input come from > the same channel. > 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? Thank you for the explanation! Regards Dimitre