zsh-users
 help / color / mirror / code / Atom feed
* Problem with early key strokes at startup
@ 2017-02-28 10:23 Sebastian Gniazdowski
  2017-02-28 21:16 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2017-02-28 10:23 UTC (permalink / raw)
  To: zsh-users

Hello,
when I startup zsh to just run a tool with Ctrl-O Ctrl-P, I get "^P" or
"^O^P" printed instead:

https://asciinema.org/a/4ez7kv28o6790ul7rha2x0oym

Maybe it's easy to fix? A thing that's a matter of robustness.

-- 
  Sebastian Gniazdowski
  psprint3@fastmail.com


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

* Re: Problem with early key strokes at startup
  2017-02-28 10:23 Problem with early key strokes at startup Sebastian Gniazdowski
@ 2017-02-28 21:16 ` Bart Schaefer
  2017-03-01  6:28   ` Sebastian Gniazdowski
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2017-02-28 21:16 UTC (permalink / raw)
  To: Sebastian Gniazdowski, zsh-users

On Feb 28,  2:23am, Sebastian Gniazdowski wrote:
}
} when I startup zsh to just run a tool with Ctrl-O Ctrl-P, I get "^P" or
} "^O^P" printed instead:
} 
} Maybe it's easy to fix?

Unfortunately not.  Typeahead (characters present on stdin before the
shell is ready to read them) is exceptionally difficult to deal with
in a portable way.  There are several lengthy comments about this in
the C code in shell startup and zle.

In this specific case, the problem is likely ctrl-O.  If you look at
output of "stty -a" you'll probably find ^O bound to something called
"flush" which is annoyingly undocumented but means to throw away all
previous input that has not already been read by whatever is connected
to the TTY device.  This is likely being seen and intepreted by the
terminal driver before zsh has a chance to change the state to "raw"
input, and there's absolutely nothing we can do about *that*.

If this is a new shell being spawned by an already-running zsh, you
can try playing around with the value of the STTY environment variable
to disable some of the special tty driver settings ahead of time (see
the zsh manual for how STTY works).  If it's not zsh you'll have to
figure out a different way to frob the driver -- and either way I do
not promise it'll work.


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

* Re: Problem with early key strokes at startup
  2017-02-28 21:16 ` Bart Schaefer
@ 2017-03-01  6:28   ` Sebastian Gniazdowski
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2017-03-01  6:28 UTC (permalink / raw)
  To: Bart Schaefer, zsh-users

On Tue, Feb 28, 2017, at 01:16 PM, Bart Schaefer wrote:
> On Feb 28,  2:23am, Sebastian Gniazdowski wrote:
> }
> } when I startup zsh to just run a tool with Ctrl-O Ctrl-P, I get "^P" or
> } "^O^P" printed instead:
> } 
> } Maybe it's easy to fix?
> 
> Unfortunately not.  Typeahead (characters present on stdin before the
> shell is ready to read them) is exceptionally difficult to deal with
> in a portable way.  There are several lengthy comments about this in
> the C code in shell startup and zle.

I'm thinking about some minimum effort try. Looked for some
initialization via "ack stty\|STTY" but didn't find it. Would move/copy
it earlier to main, that's all. Maybe it's even the case that needed
initialization is in zle module, it would fire little late then
probably.

> In this specific case, the problem is likely ctrl-O.  If you look at
> output of "stty -a" you'll probably find ^O bound to something called
> "flush" which is annoyingly undocumented but means to throw away all
> previous input that has not already been read by whatever is connected
> to the TTY device.  This is likely being seen and intepreted by the
> terminal driver before zsh has a chance to change the state to "raw"
> input, and there's absolutely nothing we can do about *that*.

I have:
cchars: discard = <undef>; dsusp = <undef>; eof = ^D; eol = <undef>;
	eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U;
	lnext = <undef>; min = 1; quit = <undef>; reprint = ^R;
	start = ^Q; status = ^T; stop = ^S; susp = <undef>; time = 0;
	werase = ^W;

-- 
  Sebastian Gniazdowski
  psprint3@fastmail.com


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

end of thread, other threads:[~2017-03-01  6:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-28 10:23 Problem with early key strokes at startup Sebastian Gniazdowski
2017-02-28 21:16 ` Bart Schaefer
2017-03-01  6:28   ` Sebastian Gniazdowski

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