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

Honor HISTCONTROL "ignorespace" and "ignoreboth" #119

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gaelicWizard
Copy link
Contributor

This PR is based on #96 and alsö accounts for if the user still sets $HISTCONTROL incompatibly when actually running hooks. If the user insists, then gracefully fall back to $BASH_COMMAND.

This PR keeps the existing behavior of automatically altering the user's configuration, but thanks to @ilya-bobyr still maintains the user's expected behavior and thanks to @cornfeedhobo does not require Bash 5.0.

This resolves #96 and closes #115.

ilya-bobyr and others added 3 commits October 23, 2021 02:49
After 3458480

    Remove ignorespace from $HISTCONTROL

and after 7e55ac1

    Follow up commit for issue rcaloras#6

    -Replace ignoreboth with simpley ignoredups

this script would remove 'ignorespace' and would replace 'ignoreboth'
with 'ignoredups'.  This effectively disables the functionality of not
adding space prefixed commands into history.  It used to happen
siliently and could be quite confusing to users who use this feature.

This script relies on the command to be in the history, but we can
mostly fix the issue by "manual" removing a whitespace prefixed command
from the history after reading it from there.
If the user still sets `$HISTCONTROL` incompatibly anyway (`ignorespace`), then gracefully fall back to a less-ideal but not-incorrect `$BASH_COMMAND`. Alsö, adopt a modification of @cornfeedhobo's suggestion that doesn't require Bash v5.
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

Successfully merging this pull request may close these issues.

[Bug] HISTCONTROL ignore* setting should be respected
2 participants