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

rg doesn't reset terminal color when interrupted #119

Closed
lambda opened this issue Sep 27, 2016 · 6 comments
Closed

rg doesn't reset terminal color when interrupted #119

lambda opened this issue Sep 27, 2016 · 6 comments
Labels
bug A bug.

Comments

@lambda
Copy link
Contributor

lambda commented Sep 27, 2016

I was grepping a large log file, and accidentally wrote a regex that matched a very large number of lines. After waiting for a minute of it just printing out lines to stdout, I killed rg with Ctrl-C. However, that left the time output and my shell prompt blue since apparently I'd interrupted it in the process of printing out a line number.

rg should probably catch SIGINT and reset the terminal color (or any other terminal changes) before exiting.

@BurntSushi BurntSushi added the bug A bug. label Sep 27, 2016
@BurntSushi
Copy link
Owner

Agreed.

Looks like we might be able to get away with the ctrlc crate.

@ticki
Copy link

ticki commented Oct 14, 2016

Or simply go into raw mode and handle C-c manually. termion allows this:

  1. Enter raw mode.
  2. Read from the TTY (termion::get_tty).
  3. Handle termion::event::Key::Ctrl('c') manually.

@BurntSushi
Copy link
Owner

termion doesn't work on Windows, right? (Which I suppose isn't strictly a problem per se, I don't even know if this issue exists on Windows.)

In any case, it seems strictly better to handle SIGTERM instead of C-c manually, since SIGTERM can come from anywhere.

@andyleejordan
Copy link
Contributor

@BurntSushi it's starting to exist on Windows with the additional support of ASCII color codes in new versions of ConHost shipped in Windows 10. (Oh god why do I know that?)

@BurntSushi
Copy link
Owner

Yeah I know, but that's too new to rely on IMO.

On Oct 18, 2016 14:47, "Andrew Schwartzmeyer" [email protected]
wrote:

@BurntSushi https://github.com/BurntSushi it's starting to exist on
Windows with the additional support of ASCII color codes in new versions of
ConHost shipped in Windows 10. (Oh god why do I know that?)


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#119 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAb34v_mASLh8OVGEitsaghaWFhfDGv-ks5q1RQ9gaJpZM4KIQ4y
.

@BurntSushi
Copy link
Owner

Yeah I know, but that's too new to rely on IMO.

On Oct 18, 2016 14:47, "Andrew Schwartzmeyer" [email protected]
wrote:

@BurntSushi https://github.com/BurntSushi it's starting to exist on
Windows with the additional support of ASCII color codes in new versions of
ConHost shipped in Windows 10. (Oh god why do I know that?)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#119 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAb34v_mASLh8OVGEitsaghaWFhfDGv-ks5q1RQ9gaJpZM4KIQ4y
.

lambda added a commit to lambda/ripgrep that referenced this issue Oct 19, 2016
If a user hits Ctrl-C to exit out of a search in the middle of printing
a line, we don't want to leave the terminal colors screwed up for them.
Catch Ctrl-C using the ctrlc crate, obtain a stdout lock to ensure that
other threads don't continue writing after we do so, reset the terminal,
and exit the program.

Closes BurntSushi#119
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug.
Projects
None yet
Development

No branches or pull requests

4 participants