Zsh Mailing List Archive
Messages sorted by:
Re: what does 'interactive' mean?
- X-seq: zsh-users 26889
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Roman Neuhauser <neuhauser@xxxxxxxxxx>, zsh-users@xxxxxxx
- Subject: Re: what does 'interactive' mean?
- Date: Tue, 10 Aug 2021 13:12:02 +0100 (BST)
- Archived-at: <https://zsh.org/users/26889>
- Importance: Medium
- In-reply-to: <YRHrWtkE6y1zdha0@isis.sigpipe.cz>
- List-id: <zsh-users.zsh.org>
- References: <YRHrWtkE6y1zdha0@isis.sigpipe.cz>
> On 10 August 2021 at 03:58 Roman Neuhauser <neuhauser@xxxxxxxxxx> wrote:
> 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.
As you say, the documentation is confusing. What it's trying to say,
but not making a good job of, is that basically the conditions
here (tty on STDIN with commands coming from it, which cause the
INTERACTIVE option to be set) define an interactive shell --- the
option is the consequence, not the cause. But then you can
actually force the option on or off (sometimes that's even useful),
so that's just a test by default.
I suppose that paragraph really needs dividing into a bit
(that doesn't necessarily belong here) that explains the logic
the shell uses to decide if it's interactive if you don't override
it, and then this bit saying how the option behaves.
The shell tests the option internally in a great number of places
to see if it's appropriate to output prompts, use the line editor,
etc. etc. Mostly this is mentioned in the manual, but only
with something like "if the shell is interactive..."
This becomes more useful if you know it's testing the
option when that happens, so somewhere we need a sentence along
the lines of "where the shell needs to decide if it is
interactive at run time, it tests the state of the INTERACTIVE shell
option. See XXXX for information on this".
In summary, the information to get across in some form is the following:
- At run time the shell tests the option INTERACTIVE to decide if it is
interactive. This is to be understood anywhere in the manual where
"an interactive shell" is mentioned.
- This option may be set or unset at shell initialisation by passing
appropriate options in the command line that invokes the shell.
- If the option is not explicitly set or unset in this way, it is
initialised to "set" if standard input is a terminal and is being used
for command input, and to "unset" otherwise.
- The option may not be altered after shell initialisation.
Of course, there may still be something I'm missing.
Messages sorted by: