Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: exec - interactive vs non-interactive shell
- X-seq: zsh-users 16072
- From: "Radoulov, Dimitre" <cichomitiko@xxxxxxxxx>
- To: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- Subject: Re: exec - interactive vs non-interactive shell
- Date: Thu, 02 Jun 2011 00:03:23 +0200
- Cc: zsh-users@xxxxxxx
- 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=
- In-reply-to: <20110601214240.6fde31de@pws-pc.ntlworld.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <4DE69918.4040205@gmail.com> <20110601214240.6fde31de@pws-pc.ntlworld.com>
On 01/06/2011 22:42, Peter Stephenson wrote:
On Wed, 01 Jun 2011 21:55:04 +0200
"Radoulov, Dimitre"<cichomitiko@xxxxxxxxx> 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" with "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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author