-
Notifications
You must be signed in to change notification settings - Fork 374
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
Disable /etc/bash_completion.d/redefine_filedir
#667
Disable /etc/bash_completion.d/redefine_filedir
#667
Conversation
This is kind of fine. But I would be happier if we'd get out of the blacklisting business altogether. I wasn't happy about it ten years ago, and I haven't grown to like it a single bit more since. No matter what we do, I suppose we should do is to ask Fedora to just remove I also don't think we want/need to support redefining our functions in the first place. People may opt to do it, but they can then deal with the possible breakage. Namespacing isn't a long term solution either. Even though we do have kind of a stable implicit API here and there, just replacing a function from an old installation with one from a newer bash-completion might or might not work. I have no actual info whether acroread.sh even exists these days in setups that are able to run the current bash-completion. But I guess it doesn't, and the blacklisting code could just go away from that point of view as well.
I think it can be done by placing a file with the desired implementation into the compat dir and name it so that it sorts (and thus loads) after Now, I'm not absolutely against this change, but what I'm trying to say with the rantish above that I'd rather like to clean up the landscape on this. |
Thank you for your thoughts!
I agree with this.
I'm interested in what has caused the problem for this specific case and how it was solved by putting
Yeah. However, as you have mentioned, this wouldn't help the case where there is an old
You are right. We anyway have several ways to work around the problem, like putting
I agree that we'd like to have a cleaner solution. Besides the clean solution, considering that I currently don't have a perfect solution, but below are my current consideration on possible solutions: 1. declare -fr _filedir?
I agree. Maybe if we would explicitly forbid redefining bash-completion functions, we might make the functions readonly by declare -fr _filedir As you have already mentioned at https://bugzilla.redhat.com/show_bug.cgi?id=677446#c7, this will produce warning messages when other scripts try to redefine the functions, but in this way, the author of such a script should notice that they are not allowed to redefine the bash-completion functions before they distribute the script. The downside of this approach is that, even if a user intentionally wants to redefine the function knowing what they are trying to do, the user cannot redefine the functions. Actually, my framework # copy the definition of the function to another name
eval "_original$(declare -f _filedir)"
# overwrite the original function
_filedir() {
_inserted_command1
_original_filedir "$@"; local exit_status=$?
_inserted_command2
return "$exit_status"
} Currently, 2. Namespacing?
I agree that namespacing doesn't solve the problems in every possible case, but for external completion writers, I think the namespace implies that the function name is somehow reserved so that the chances that the other people try to redefine the function will decrease. Of course, the original name should also be preserved because existing external completions rely on these functions. We may write as _comp_filedir() {
...
}
# Deprecated: this is the old name for compatibility.
_filedir () { _comp_filedir "$@"; } 3. Exposing the shell variable for the blacklist?This is the least intrusive change in my mind. _comp_init_blacklist_glob=${BASH_COMPLETION_COMPAT_BLACKLIST-} In this way, we don't have to bother with the blacklist management by ourselves in the |
https://src.fedoraproject.org/rpms/bash-completion/pull-request/7
Comments in that bug indicate that a fix was applied to the
I would personally be fine with assuming
This I'm not a fan of. There's no way of knowing if a user knows what they're doing and they really do want to replace
Something like this I could accept. (Or the option to just removing all blacklist support, as mentioned above.)
I haven't followed all the discussion through, but this wouldn't be enough for users with older versions of bash-completion installed, such as the 2.1 on RHEL 7.8 -- they would additionally need to upgrade their bash-completion. But maybe that was implied. |
Thank you for creating changes to the Fedora
I see. Thank you for the explanation.
OK. However, now I think
I actually have a question related to the usage of this user settings
I'd like to use it to disable
Yes, I was implicitly assuming that the user gets the latest version of |
ef1a42c
to
b7857fb
Compare
For per user config, the profile.d loader sources |
Oh, I see. I have been somehow thinking that I will later update the PR so that it adds the variable |
9bc1603
to
60a0cbd
Compare
I have updated the patch. I thought maybe I also need to update |
60a0cbd
to
f1bdeb0
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.
LGTM with a few doc suggestions, feel free to merge after addressing the way you see fit.
WDYT, should we note that we're ignoring files we treat as editor backups etc unconditionally under the hood, i.e. one does not need to address them by setting BASH_COMPLETION_COMPAT_IGNORE
? No strong feelings here.
Re |
fe000fc
to
2939160
Compare
Thank you! I have applied these changes.
Yeah, this sounds nice! But it seems not quite practical after some consideration. Looking at the definition of ./bash_completion:1327:_backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))'
./bash_completion:1337: local -a svcs=($xinetddir/!($_backup_glob))
./bash_completion:1354: $(printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions|README)))
./bash_completion:1401: for svc in "$svcdir"/!($_backup_glob); do
./bash_completion:2419: [[ ${_comp_file##*/} != @($_backup_glob|Makefile*|${BASH_COMPLETION_COMPAT_IGNORE-}) &&
./completions/cvs:171: COMPREPLY=($(compgen -X "$_backup_glob" -W '"${files[@]}"' \
./completions/invoke-rc.d:15: services=($sysvdir/!(README*|*.sh|$_backup_glob))
./completions/update-rc.d:15: services=($sysvdir/!(README*|*.sh|$_backup_glob)) If we want to manage the backup-filename pattern consistently, we need to set as BASH_COMPLETION_COMPAT_IGNORE='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save)))|Makefile*|$_user_specified_compat_ignore)' I don't have a simpler solution for this for now. I think we can just keep the current setup until someone raises an issue related to the ignored backup files in the compatibility directory. |
Thank you! I have now pushed it to the mater 2b6785d. |
I agree it's not practical to ask users to manage the backup globs in any way at this point. But that's not what I meant, by "should we note" I meant if we should add a comment near |
Ah, I see. I misunderstood your previous comment. Thank you for your explanation. I'll later update it. |
This was merged 2020-01-07. |
2939160
to
ca623ea
Compare
Thank you. I also updated the description in |
ca623ea
to
59bbd3f
Compare
I've no idea how but this (https://src.fedoraproject.org/rpms/bash-completion/pull-request/7) broke directory completion for me: https://bugzilla.redhat.com/show_bug.cgi?id=2070852 . In short, |
Ok, false alarm. It turns out I did have this old acroread installed and it was overriding the |
Thanks for the information! So, does it mean that the up-to-date version of Acrobat Reader still installs the broken script? |
There's no up-to-date version. I'm talking about the ancient 9.5.5 version from 2013 that I keep around to open some PDF forms unsupported by open-source PDF readers. |
Thank you for the information! After #539 is settled, we are going to merge this PR where we provide a way to work around the problem for users (cf the updated description in |
59bbd3f
to
5c54448
Compare
We remove the workaround for the "acroread.sh" and instead expose a customization point via the new shell variable "BASH_COMPLETION_COMPAT_IGNORE" so that the user can specify the files in "BASH_COMPLETION_COMPAT_DIR" to ignore. Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
5c54448
to
9cb3ad1
Compare
I'm not sure what is the most appropriate way to solve the issue, but let me explain the issue here.
Fedora (and probably its downstream RHEL and CentOS) has
/etc/bash_completion.d/redefine_filedir
which tries to overwrite the shell function_filedir
with the version defined in/usr/share/bash-completion/bash_completion
. This doesn't cause the problem as far as the user uses the distribution version ofbash-completion
in/usr/share
. However, if one downloads and uses the latest version ofbash-completion
, this introduces the inconsistency because_filedir
inredefine_filedir
is not necessarily the same as the downloaded version.The reason why Fedora tries to overwrite
_filedir
is explained in/etc/bash_completion.d/redefine_filedir
:Actually, its workaround is already implemented in bash-completion itself in commit 2a05603, so there is no need to source
redefine_filedir
in the latest version ofbash-completion
. So I'd propose addingredefine_filedir
along withacroread.sh
in the blacklist.[When we want to use
acroread.sh
] By the way, the blacklist is somehow made empty in the distributed version of bash-completion in Fedora. Maybe it is because they still want to allowacroread.sh
. But, even when we intendedly sourceacroread.sh
, I'm not sure ifacroread.sh
still has the problem after ten years.[Background of PR] Actually, I haven't faced with an explicit inconsistency by the older version of
_filedir
, but the older version of_filedir
caused the performance issue. Currently the result ofcompgen
is processed byIFS=$'\n'; COMPREPLY=($(compgen ...))
, but an older version of_filedir
had usedwhile read -r line: do ... done <<< $(compgen ...)
which is very slow in the directory with thousands of files. This was discussed inI tried to replace
_filedir
with the latest implementation, but the problem is that there is no way to disableredefine_filedir
forcing an old_filedir
(other than disabling entire/etc/bash_completion.d
by settingBASH_COMPLETION_COMPAT_DIR
) even though I am using the latest version ofbash-completion
.As @scop has mentioned in https://bugzilla.redhat.com/677446, maybe we can think about namespacing bash-completion functions (cf #537) for this. Nevertheless I tend to think we can include
redefine_filedir
in the blacklist as far as we haveacroread.sh
there. Maybe there is another approach. What do you think?