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

Re: When is STTY ignored?

2017-05-29 17:02:09 -0700, Bart Schaefer:
> On May 29,  9:36pm, Stephane Chazelas wrote:
> }
> } It's not very clear to me when one may use STTY.
> It applies only to external commands, not those executed within zsh
> (functions, loops, other multiline constructs, builtins).
> If it's in the environment of a function et al., it'll apply to all
> external commands run from within that construct.

Thanks. That doesn't seem to be the whole story though.

See the examples I gave

"line" is an external command. "eval" and "command" are builtin

STTY=-echo line
STTY=-echo command line
f() line; STTY=-echo f

Do work, but not

STTY=-echo eval line

About zsh -c, it looks like it "works" as long as there's only one

zsh -c 'STTY=-echo line'

works (well, it doesn't seem to restore the settings afterwards)
but not

zsh -c 'STTY=-echo line; exit'

It seems it never works in scripts even if they contain a single
command. With scripts source from interactive shells, they seem
to "work" but don't restore the tty settings.

See also:

line | STTY=-echo wc -c
STTY=-echo head -n1 /dev/tty < /dev/null

which don't "work" (even if they called stty, stty would fail
because stdin is not a terminal anyway, but that would still be
worth documenting).


(STTY=-echo line; STTY=-echo line); line

the "-echo" is only applied to the 2nd and 3rd "line"
invocations (instead of 1st and 2nd).

And the issue when several are stacked mentioned before:

$ f() STTY=-onlcr line; STTY=-echo f; stty
      speed 38400 baud; line = 0;
                                 -brkint -imaxbel iutf8

-echo not applied, -onlcr not restored.

It would be worth documenting that it can only be used in
interactive shells and only for the simplest case of one simple
external command at the prompt, not in subshell, and without
stdin redirection


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