1

I'm facing an strange issue, I'll add a photo since is better to explain what's happening

tty issue in gnome-terminal

As you can see. After using git log and exit (either pressing q or Q or :q or ^C), I'm not able to use more commands.

After googling a bit I came to the stty sane command, which seems to fix my terminal. But I can't tell why or how does it fix gnome-terminal.

As far as I can see, before and after fixing it stty -a shows the same output.

Any idea or suggestion about how to start debugging it?

I'm using gnome terminal for GNOME 3.22.2 using version 0.46.2 from VTE +GNUTLS

EDIT:

Thanks to the answer I took a second look to both configurations and I can see these differences

chris@Gentoo ~ $ diff stty-bad stty-good 
4c4
< werase = ^W; lnext = <undef>; discard = ^O; min = 1; time = 0;
---
> werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
6c6
< -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl 
ixon -ixoff
---
> -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl 
ixon -ixoff
9c9
< isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -
tostop -echoprt
---
> isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop 
-echoprt

This still is a long list to check, I'll read as much as I can from those options, but that leaves the answer... how does stty sane fix the problem and what is causing it, since git log is not the real problem. I tried with git --no-pager log and after a while printing commits, I press ^C and the same happens...

EDIT 2:

Ok, after switching each option the root seems to be the -echo variable. But that leaves me just one question. Why does git log or ^C change the default echo variable. Where could I find the root? is it git? less (git log's pager)? or gnome-terminal? or even stty?

1 Answer 1

1

That is, git log isn't cleaning up properly... Applications that wait for single keys (such as vi, less) put the terminal into a mode that suppresses echo, eliminates special control characters, etc., just to make it simple. But if they do not cleanup, that leaves the terminal unusable.

The stty sane command simply sets the terminal modes to a predetermined value. If your editing-characters don't work, that fixes it (except for some Unix platforms where stty sane sets the erase character to @, etc). I use a script for comparing stty output, but it's not short...

Your photograph has at least one difference (I see -icanon, which would be enough to interfere with line-editing). For reference, here's what I see after stty sane:

$ stty -a
speed 38400 baud; rows 40; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

You might want to look closer, just in case.

1
  • I guess a followup question is why the shell lets programs change settings in the outer envorment - that is, why it doesn't revert changes programs make when they are not in the foreground. Oct 16, 2017 at 15:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .