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
Avoid showing the 130 error code after hitting ^C #827
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting idea. I can see why one would want this. And I likely will use this once we merge it. However, it needs to be configurable.
- Add a config option to control this, like
LP_HIDE_EMPTY_ERROR
. Don't forget to add docs for it as well. - The tracking variable
_LP_NOT_A_REAL_COMMAND
is very confusing. Rename it to_LP_REAL_COMMAND
, and invert the Boolean logic.
liquidprompt
Outdated
if (( _LP_NOT_A_REAL_COMMAND )); then | ||
lp_error=0 | ||
fi | ||
# zsh doesn't run __lp_before_command, so we set it here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bash also doesn't run __lp_before_command()
if all the features that depend on it are disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to post a detailed review of how you missed a couple important things, but the more I dug and reread, I realized that you are fighting against a terrible codebase, which is my fault of course.
So I decided to fix things up as I saw them. Take a look at my new branch rework/preexec, specifically the first two commits eb334b2 and 436b1b5. This largely reworks and improves how preexecs are handled, no longer runs them on empty prompts ([Enter]), and also fixes a related issue where runtime display was not cleared after an empty prompt.
After those fixes, your change is super simple, so I did that too in commit 1be449e. Please take a look at these 3 commits, and let me know if everything makes sense. If so, I'll merge my first 2 into master
, and you can continue from there.
If you accept my (our) commit 1be449e, then you pretty much are only missing docs. You will want to add a section for your new config option here. Remember to detail both scenarios this will trigger.
LGTM +1 Let me prepare the docs now. |
ed06664
to
8ff91be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, except for one "spelling error":
config.rst:1182: : Spell check: Ctrl: after the user hits Ctrl-C or submits an empty command (i.e. empty string.
You will need to add Ctrl
to the docs/spelling_wordlist.txt
file.
When a user hits ^C on command line to cancel entering a lengthy command, $! in __lp_set_prompt is set to 130 (128 + SIGINT). Displaying this error on the input line (especially in warning colours) makes little sense.
8ff91be
to
5d0a24d
Compare
When a user hits ^C on command line to cancel entering a lengthy command, $! in __lp_set_prompt is set to 130 (128 + SIGINT). Displaying this error on the input line (especially in warning colours) makes little sense. Therefore, liquidprompt should check if the command submitted is a real command or is it part of PROMPT_COMMAND in which case the error does not come from a user's command and should not be presented.
Technical checklist:
IFS
_LP_FIRST_INDEX
_LP_PERCENT
_LP_SHELL_*
)tests/test_*.sh
files)tests.sh
shellcheck.sh
(requires shellcheck)... versionadded:: X.Y
or.. versionchanged:: Y.Z
docs/docs-lint.sh
(requires Python 3 andrequirements.txt
installed (
cd docs/; python3 -m venv venv; . venv/bin/activate; pip install -r requirements.txt
))