Bug 994646 - attempting tab-completion with "TZ=" returns files and directories, not time zones
Summary: attempting tab-completion with "TZ=" returns files and directories, not time ...
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: bash-completion
Version: 19
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Ville Skyttä
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-08-07 17:11 UTC by Steve Tyler
Modified: 2013-08-09 17:17 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-08-08 09:54:29 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Steve Tyler 2013-08-07 17:11:19 UTC
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:

$ TZ=[tab]
bar.dir/ foo.txt  

NB: TZ is a POSIX environment variable:
8. Environment Variables
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html

Version-Release number of selected component (if applicable):
bash-completion-2.1-2.fc19.noarch
bash-4.2.45-1.fc19.x86_64

How reproducible:
Always.

Steps to Reproduce:
1. $ TZ=[tab]

Actual results:
A list of files and directories is displayed:
$ TZ=[tab]
bar.dir/ foo.txt  

Expected results:
A list of time zones is displayed.

Additional info:

With zsh, a list of time zones is displayed:

% TZ=[tab]
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

zsh-5.0.2-4.fc19.x86_64

Comment 1 Ville Skyttä 2013-08-08 09:54:29 UTC
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:

http://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git;a=commitdiff;h=3f144beb721525821136f76f53a3147b4688d331

Comment 2 Steve Tyler 2013-08-08 10:26:34 UTC
Your upstream patch looks like it _fixes_ this bug.
Why did you close it CANTFIX instead of UPSTREAM?

Comment 3 Ville Skyttä 2013-08-08 11:02:54 UTC
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.

Comment 4 Steve Tyler 2013-08-08 11:19:01 UTC
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
SM5..UGT.    /usr/share/bash-completion/bash_completion

2. Log out.
3. Log in.

Comment 5 Ville Skyttä 2013-08-08 11:23:56 UTC
You need updated completions/export in /usr/share/bash-completion/completions from upstream too.

Comment 6 Steve Tyler 2013-08-08 12:01:44 UTC
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 
SM5..UGT.    /usr/share/bash-completion/bash_completion
SM5..UGT.    /usr/share/bash-completion/completions/export

BTW, I didn't know tab-completion requires so much infrastructure:
$ rpm -ql bash-completion | wc -l
563

Comment 7 Ville Skyttä 2013-08-08 12:10:25 UTC
(In reply to Steve Tyler from comment #6)
> $ rpm -ql bash-completion | wc -l
> 563

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.

Comment 8 Steve Tyler 2013-08-08 12:34:30 UTC
That sounds like a valuable optimization:
$ rpm -ql bash-completion | grep /usr/share/bash-completion/ | xargs cat 2>/dev/null | wc -l
81051

Comment 9 Steve Tyler 2013-08-09 17:17:06 UTC
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
29839

That's still a lot of lines ...


Note You need to log in before you can comment on or make changes to this bug.