Red Hat Bugzilla – Bug 994646
attempting tab-completion with "TZ=" returns files and directories, not time zones
Last modified: 2013-08-09 13:17:06 EDT
Description of problem:
Attempting tab-completion with the TZ environment variable results in a list of files and directories, not a list of time zones:
NB: TZ is a POSIX environment variable:
8. Environment Variables
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. $ TZ=[tab]
A list of files and directories is displayed:
A list of time zones is displayed.
With zsh, a list of time zones is displayed:
Africa/ CST6CDT GMT Israel NZ ROK
America/ Cuba GMT0 Jamaica NZ-CHAT Singapore
Antarctica/ EET GMT-0 Japan Pacific/ Turkey
Arctic/ Egypt GMT+0 Kwajalein Poland UCT
Asia/ Eire Greenwich Libya Portugal Universal
Atlantic/ EST Hongkong MET posix/ US/
Australia/ EST5EDT HST Mexico/ posixrules UTC
Brazil/ Etc/ Iceland Mideast/ PRC WET
Canada/ Europe/ Indian/ MST PST8PDT W-SU
CET GB Iran MST7MDT right/ zone.tab
Chile/ GB-Eire iso3166.tab Navajo ROC Zulu
Completing the first argument is not something that can be done with bash's programmable completion features as far as I know. On the other hand, for export and friends (at least env, declare, typeset) it can be done, and is now done for export upstream:
Your upstream patch looks like it _fixes_ this bug.
Why did you close it CANTFIX instead of UPSTREAM?
Because as said, the requested feature cannot AFAIK be implemented. The upstream patch implements "export TZ=<TAB>" completion, not plain "TZ=<TAB>" which is what was requested.
Thanks for the clarification.
The upstream version doesn't appear to work with:
$ export TZ=[tab]
That returns a list of files and directories, not a list of time zones.
To test the upstream version, do I need to do anything in addition to these?
1. Copy upstream version of bash_completion into /usr/share/bash-completion/:
$ ls /usr/share/bash-completion/
bash_completion bash_completion.ORIG completions/ helpers/
$ rpm -V bash-completion
2. Log out.
3. Log in.
You need updated completions/export in /usr/share/bash-completion/completions from upstream too.
Verified. Thanks for the patch.
$ export TZ=U[tab]
UCT Universal US/ UTC
$ export TZ=UTC ;date
Thu Aug 8 11:51:50 UTC 2013
$ rpm -V bash-completion
BTW, I didn't know tab-completion requires so much infrastructure:
$ rpm -ql bash-completion | wc -l
(In reply to Steve Tyler from comment #6)
> $ rpm -ql bash-completion | wc -l
We could (and used to) lump everything into just a couple of files, but since version 2.0 splitting most things into per command completion files allows us to dynamically load needed functions from them on demand which allows huge shell startup time savings.
That sounds like a valuable optimization:
$ rpm -ql bash-completion | grep /usr/share/bash-completion/ | xargs cat 2>/dev/null | wc -l
The pipeline in Comment 8 follows links and omits completions from other packages.
FWIW, here is a better line count:
$ find /usr/share/bash-completion/ -type f | xargs cat | wc -l
That's still a lot of lines ...