Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal settings do not get restored on exit when using bash #858

Closed
asomers opened this issue Jan 26, 2024 · 1 comment
Closed

Terminal settings do not get restored on exit when using bash #858

asomers opened this issue Jan 26, 2024 · 1 comment

Comments

@asomers
Copy link

asomers commented Jan 26, 2024

Describe the bug
Ever since I ported my applications from Termion to Crossterm, the terminal settings do not get restored when the application quits. But that only happens if my login shell is bash. If my login shell is fish, then everything works fine. Is there some standard teardown command needs to be used with Crossterm?

To Reproduce

If using ZFS on FreeBSD (and presumably Linux too)
Steps to reproduce the behavior:

  1. git clone git@github.com:asomers/ztop.git
  2. cd ztop
  3. cargo run
  4. press 'q'
  5. type 'stty' and press Enter
  6. Observe this garbled output
speed 9600 baud;
                lflags: -icanon -isig -iexten -echo echoke echoctl
                                                                  iflags: -icrnl -ixon -ixany -imaxbel ignbrk -brkint
                                                                                                                     oflags: -opost tab0
                                                                                                                                        cflags: cs8 -parenb
  1. Type anything else and observe that commands aren't visibly echoed to the screen

If not using ZFS, but still using FreeBSD

  1. git clone git@github.com:asomers/gstat-rs.git
  2. cd gstat-rs
  3. cargo run
  4. press 'q'
  5. Observe this same problems as above

Expected behavior
When the application exits, the terminal's original behavior should be restored. Keypresses should be echoed to the screen, and newlines should include a carriage return.

OS

  • FreeBSD 13.2, 14.0, and 15.0-CURRENT

Terminal/Console
xterm-256color, tmux-256color, and reportedly some kind of OSX terminal, too.

@asomers
Copy link
Author

asomers commented Jan 26, 2024

Oh, I think I've figured out. I was missing crossterm::terminal::disable_raw_mode. I should've read the docs better. I guess I was just confused because I didn't need that with Termion, nor with certain shells.

@asomers asomers closed this as completed Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant