-
Notifications
You must be signed in to change notification settings - Fork 903
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
Reset colors after abnormal exit #474
Comments
Ruh roh shaggy. What executable are you using? powershell.exe? cmd.exe? Something else like conemu? |
cmd.exe on Windows 10.0.10565 |
Weird that this is going on. I haven't seen the behavior yet. |
I can reproduce when you interrupt using ctrl-C in the right moment (while choco install showing an error message in red for instance). I am running cmd.exe as admin. |
I can reproduce this as well (my last comment was 2015) and I hadn't reproduced it by then. By now I've done it many a time and the problem is once it is exited, there is nothing to reset. Maybe catch and reset before it fully exits. The problem is the code that handles this is in log4net - no idea why it gets stuck. Currently the only thing to do is close and reopen your shell. |
@ferventcoder another option could perhaps be to hook into the CancelKeyPressed event, and cancel the currently running task, doing cleanup and then reset the console colors? Never used it myself though, so I don't know how well that works for that event. |
We already have code set for handling the cancel - https://github.com/chocolatey/choco/blob/0c11effebeadbd6bec1d1a16206942aef4204446/src/chocolatey/infrastructure/commandline/ExitScenarioHandler.cs. We went much more low level on that - maybe we didn't have to! All we'd need in there is to ensure we reset colors. |
I see, in that case. |
@AdmiringWorm Definitely worth a shot to add. It won't apply if you don't see the warning message though. Sometimes when you call control+c it just exits without a warning. That seems to be when the colors get messed up. So there is probably more to do to ensure that it is capturing those events. If you want to create a PR for this, we'd accept it! |
sure thing, I can do that. |
I'm just guessing, but it could be that a different signal is sent instead (especially in cases where the user have done |
That's a one line change in the code I shared above to remove that There are more graceful ways we could clean up, which I believe is captured in another open ticket here. |
This will be in 0.10.9 |
With this commit the console is always reset when an abnormal exit has occurred. Without this change, all customizations of the console may still be present when choco have exited.
* stable: (version) 0.10.9 (doc) update release notes (GH-474) Adding reset of console on abnormal exit (doc) update release notes (GH-1526) Provide friendly messages on exit codes (maint) update tab expansion (GH-1365) Do not warn on missing folders (doc) update release notes (GH-1524) Capture password when only user is provided
Still an issue with chocolatey v1.2.1 on Windows 10. Run |
Hi @john-aws, Thanks for your comment. As this particular issue was closed over 4 years ago, would you mind opening a new issue and filling out the template? Of particular help would probably be a video of the issue happening, as well as consistent reproduction steps. |
If chocolatey exits abnormally, this message appears:
Afterwards, the prompt color needs to be reset. (In my case, it was red.)
The text was updated successfully, but these errors were encountered: