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

what does 'interactive' mean?



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




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