-
-
Notifications
You must be signed in to change notification settings - Fork 672
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
lib/bourne-shell.sh: Don't force-load bash-completion #572
base: master
Are you sure you want to change the base?
Conversation
It's already done better by the "system" completion module, and doing it there too makes disabling it impossible and debgging issues harder.
We have been sourcing bash-completion as many times as the number of the installations and entry points that we can find. However, only one instance of bash-completion is enough. We also re-order the detection to adjust the precedence.
…rne-shell The search that has been in lib/bourne-shell.sh is slightly different from that in completions/system.completion.sh. We integrate the former into the latter. * We add a search location `/usr/share/bash-completion/bash_completion` for bash-completion. This is the standard location for bash-completion v2. We have been only checking /etc/bash_completion which is bash-completion v1. * We also add a guard for the POSIX mode. Older versions of bash-completion have an issue with the POSIX mode. In particular, bash-completion v1 can only be used with with the macOS Bash 3.2, but bash-completion v1 does not work well in the POSIX mode. * We also add a guard for already loaded bash-completion. Other system configuration might already load bash-completion. We skip loading bash-completion when we detect an existing bash-completion settings in tbe current shell environment.
43a4ebc
to
d291140
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.
Thanks. I added system
to the default set of the completions in the ~/.bashrc
template because bash-completion
is not loaded by default after the suggested change. The users who want to disable bash-completion
can remove system
from the completions
array.
However, one issue is that we cannot enable the system
completion for existing users because the updating process of Oh-My-Bash doesn't update the user's ~/.bashrc
(which might already be edited by the user). This means that by applying those changes, we disable bash-completion
of existing users, which is a problem. Do you have a solution?
@akinomyoga is there a way to perhaps print a warning message during upgrade? Wasn't "system" in the default If we absolutely want to keep the current behaviour, we can:
That way newer users and those who explicitly add the variable it can get the new behaviour while users with older We can call the variable something like |
Please let me know if you want me to add what I've described. Since you've modified the PR I don't want to make further changes without your approval |
It seems no. I've checked the code to update OMB. The upgrading is performed by a script in the older version of OMB (before upgrading), and currently, there doesn't seem to be a way to change the behavior for the new version of OMB after upgrading.
No. It's never been there. From the beginning when the
I'm not sure...
That's technically possible, but if we would have such a variable, I'd rather do that the other way around. That is,
I want to think about it more. |
That will mean we keep having duplicate code. Perhaps we can do one of:
Go ahead. |
. "$BREW_PREFIX"/etc/bash_completion | ||
# homebrew/versions/bash-completion2 (required for projects.completion.bash) | ||
# is installed to this path | ||
if [[ -f "$BREW_PREFIX"/share/bash-completion/bash_completion ]]; then |
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.
One request I would make here is the ability to set a BASH_COMPLETION_DIR
, and check it as a potential location.
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'm not sure if that is useful. If you know the location of bash_completion and needs to specify it explicitly, how is it different from source '<path to bash_completion>/bash_completion'
? A plugin that allows users to write
BASH_COMPLETION_DIR='<path to bash_completion>'
plugins+=(system)
instead of
source '<path to bash_completion>/bash_completion'
doesn't seem useful. It actually complicates the configuration.
Also, the plugin name system
implies loading bash-completion
in a system package. Allowing the configuration for an arbitrary location of bash-completion
doesn't match the plugin's name. If the configuration would be added, the plugin name should also be changed.
In addition, BASH_COMPLETION_*
is a kind of variable namespace used by bash-completion
[1,2], so we should avoid defining a variable of the form BASH_COMPLETION_*
outside bash-completion
. It might conflict in the future. We should use OMB_COMPLETION_SYSTEM_BASH_COMPLETION_DIR
or something.
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.
Didn't think of just sourcing the file directly. Good call
Its already done better by the "system" completion module, and doing it there too makes disabling it impossible and debgging issues harder.