zsh-users
 help / color / mirror / code / Atom feed
* what does 'interactive' mean?
@ 2021-08-10  2:58 Roman Neuhauser
  2021-08-10  9:04 ` Thomas Paulsen
  2021-08-10 12:12 ` Peter Stephenson
  0 siblings, 2 replies; 16+ messages in thread
From: Roman Neuhauser @ 2021-08-10  2:58 UTC (permalink / raw)
  To: zsh-users

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


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-08-10 23:31 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-10  2:58 what does 'interactive' mean? Roman Neuhauser
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

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).