From: Roman Neuhauser <neuhauser@sigpipe.cz>
To: zsh-users@zsh.org
Subject: what does 'interactive' mean?
Date: Tue, 10 Aug 2021 04:58:34 +0200 [thread overview]
Message-ID: <YRHrWtkE6y1zdha0@isis.sigpipe.cz> (raw)
hello,
i was looking for a way to start zsh with an ad-hoc initialization
file: the shell would would source the file (instead of or after the
usual startup files, does not matter right now) and drop into the
ZLE. if there's a way i haven't found it, but whatever: i'm here to
complain that the manual never defines "interactive shell".
(solutions to my original problem are welcome too.)
i started from zsh(1):
-i Force shell to be interactive. It is still possible to specify
a script to execute.
noting how it says "execute" as opposed to "read commands from" or
"source" i didn't really expect "zsh -i script" to do what i needed
but, as a naive user equipped with the common-use understanding of
"interactive shell" supported by zsh(1) itself ("Zsh is a UNIX
command interpreter (shell) usable as an interactive login shell"
-- that's the informal use right there), i definitely expected to
get the prompt. well i wouldn't be here if it worked that way...
so what *is* an "interactive shell"?
here's a few notes about my path through the manual tonight.
zshzle(1) and zshoptions(1) use two different vocabularies to
describe one thing, that's something to avoid. define your terms
and stick to them!
DESCRIPTION
If the ZLE option is set (which it is by default in interactive
shells) and the shell input is attached to the terminal, the
user is able to edit command lines.
the description of INTERACTIVE in zshoptions(1) contains
*no mention of its effects*!
INTERACTIVE (-i, ksh: -i)
This is an interactive shell. This option is set upon
initialisation if the standard input is a tty and commands are
being read from standard input. (See the discussion of
SHIN_STDIN.) This heuristic may be overridden by specifying a
state for this option on the command line. The value of this
option can only be changed via flags supplied at invocation of
the shell. It cannot be changed once zsh is running.
SHIN_STDIN (-s, ksh: -s)
Commands are being read from the standard input. Commands are
read from standard input if no command is specified with -c and
no file of commands is specified. If SHIN_STDIN is set [...]
ZLE (-Z)
Use the zsh line editor. Set by default in interactive shells
connected to a terminal.
as you can see in the snippets below, -i implies -Z *even when stdin
is /dev/null!* which is not what the docs seem to say, and the
independence of ZLE option from ZLE repl is far from obvious.
% :>|s
% zsh -fi s; echo NOPE
NOPE
% cat >|s <<\EOF
> [[ -t 0 ]] && echo input is from terminal
> set -o > >(grep -w -e zle)
> EOF
% zsh -fi s
input is from terminal
zle on
% zsh -fi s </dev/null
zle on
% cat >|s <<\EOF
> [[ -t 0 ]] && echo input is from terminal
> set -o > >(grep -w -e interactive -e shinstdin -e zle)
> EOF
% zsh -fi s
input is from terminal
interactive on
shinstdin off
zle on
--
roman
next reply other threads:[~2021-08-10 2:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-10 2:58 Roman Neuhauser [this message]
2021-08-10 9:04 ` Thomas Paulsen
2021-08-10 13:00 ` Roman Neuhauser
2021-08-10 12:12 ` Peter Stephenson
2021-08-10 13:47 ` Roman Neuhauser
2021-08-10 13:54 ` Peter Stephenson
2021-08-10 15:30 ` Ray Andrews
2021-08-10 16:34 ` Peter Stephenson
2021-08-10 16:48 ` Ray Andrews
2021-08-10 19:00 ` Bart Schaefer
2021-08-10 22:33 ` Ray Andrews
2021-08-10 19:30 ` Lawrence Velázquez
2021-08-10 22:38 ` Ray Andrews
2021-08-10 23:08 ` Bart Schaefer
2021-08-10 23:26 ` Ray Andrews
2021-08-10 23:30 ` Bart Schaefer
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=YRHrWtkE6y1zdha0@isis.sigpipe.cz \
--to=neuhauser@sigpipe.cz \
--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).