Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: what does 'interactive' mean?

On Tue, Aug 10, 2021 at 9:48 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> Just when I thought I understood it :-(  So 'non-interactive' might be
> interactive after all?  It would take some writing skill to really
> elucidate this.

You're WAY over-thinking this.

Computer operations are called "interactive" when they in some way
respond to user input, be that via keyboard, mouse, voice command,
electrodes on the skull, etc. as part of normal operation.

A shell is a command interpreter.  When the shell is described as
"interactive", that is intended to mean that the interpreter itself
responds to user input, for example by printing a prompt and waiting
in between interpreted commands or when a command is incomplete.
That's distinct from any of the commands executed BY the interpreter
doing something similar; that is, just because you can write a script
that invokes the "read" builtin with consequentially a prompt and a
wait for input, doesn't make the interpreter interactive, it just
makes your script interactive.

There are two ways this can get muddied:
(1)  Shell options such as INTERACTIVE and SHIN_STDIN can be forced on
at the command line, which may cause the interpreter to behave AS IF
it is receiving user input even when it is not.
(2) The design of the file descriptor system is such that a device
that interacts with the user can be substituted for almost any other
input, so the interpreter can be caused to receive user input even
when it does not "expect" to behave in an interactive manner.
"Interactions" such as exiting on a keyboard interrupt are a special
case of this: it's not the shell but instead the interactive device
(terminal) that receives the keyboard input, and translates it into a
signal which is delivered by the operating system.  This does NOT make
for an "interactive shell".

Roman is making an effort to quash the documentary imprecision when
describing the cases in which the interpreter behaves (or not) as if
it is receiving user input (no matter whether it actually is, or it
has been forced into that behavior).  There's really no useful way to
explain (2) within the documentation of the shell.

Messages sorted by: Reverse Date, Date, Thread, Author