Bug 994659

Summary: presetting environment variable inhibits tab-completion of command
Product: [Fedora] Fedora Reporter: Steve Tyler <stephent98>
Component: bashAssignee: Ondrej Oprala <ooprala>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: admiller, ooprala, ovasik, sheltren, stephent98, tsmetana, ville.skytta
Target Milestone: ---Keywords: FutureFeature, Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-04-01 10:29:31 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Steve Tyler 2013-08-07 17:45:31 UTC
Description of problem:
Presetting an environment variable on the command-line inhibits tab-completion of the command:

Tab-completion does not occur:
$ TZ=UTC journalct[tab]

Tab-completion occurs:
$ journalct[tab]

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=UTC journalct[tab]

Actual results:
Tab-completion does not occur.
Pressing tab has no effect.

Expected results:
The command is completed:
$ TZ=UTC journalctl
                  ^
Additional info:
The use-case is setting the time zone for the timestamps in journalctl output:
Bug 991678, Comment 21.

Comment 1 Ville Skyttä 2013-08-08 11:10:15 UTC
AFAIK there's nothing that can be done about this in bash-completion, it's a bash thing -- our completion functions simply aren't invoked in those kinds of command lines:

$ foo() { echo ; echo "in foo"; }
$ complete -F foo foo

$ foo <TAB>
in foo

$ foo=bar foo <TAB>
# filename completion occurs

Comment 2 Roman Rakus 2013-08-09 14:44:00 UTC
I'm not much familiar with bash completion, but this looks like missing feature.

I will take a look on it.

Comment 3 Steve Tyler 2013-08-09 14:55:02 UTC
Thanks, Roman.

The journalctl completions are in the systemd package, not the bash-completion package:

$ rpm -ql systemd | grep completions/journalctl
/usr/share/bash-completion/completions/journalctl

Comment 4 Ville Skyttä 2013-08-10 07:55:41 UTC
Steve BTW this has nothing to do with the bash-completion or journalctl packages or completions, see comment 1.

Comment 5 Steve Tyler 2013-08-10 08:08:41 UTC
FYI, Comment 3 was an FYI. :-)

Presumably some completions will need to be installed to test the bash fixes. Or am I mistaken? Can completions be tested without completions?

Comment 6 Ville Skyttä 2013-08-10 08:31:34 UTC
Comment 1 contains a completion for command foo, no need to install anything besides entering those two lines and start testing.

Comment 7 Steve Tyler 2013-08-10 09:50:42 UTC
Thanks for your clarification. That's very interesting. bash has a lot of features I don't know anything about ...

$ fo[tab]
fold          font2c        fonttosfnt    foo           foomatic-rip  foo.sh        for           formail       
$ foo[tab]
foo           foomatic-rip  foo.sh        
$ foo [tab]
in foo
[tab]
in foo
[enter]

in foo
$

$ complete | grep foo
complete -F foo foo
$ 
$ typeset -f foo
foo () 
{ 
    echo;
    echo "in foo"
}
$

Comment 8 Roman Rakus 2013-08-14 13:41:44 UTC
In this case the bash is trying filename completion. It could be somehow doable to learn bash (readline) to perform command completion.

Comment 9 Roman Rakus 2013-08-15 13:04:39 UTC
I'm testing bash-4.3-beta from upstream testing branch and this feature is working.
It will appear in next release of bash.

Comment 10 Steve Tyler 2013-08-15 15:04:07 UTC
What test case are you using?

$ foo() { echo ; echo "in foo"; }
$ complete -F foo foo

$ TZ=UTC fo[tab] # completion does not occur here

$ fo[tab] # this works as expected
fold          font2c        fonttosfnt    foo           foomatic-rip  foo.sh        for           formail       

$ echo $BASH_VERSION               
4.3.0(1)-beta

bash-4.3-beta.tar.gz downloaded from here:
http://git.savannah.gnu.org/cgit/bash.git/

Comment 11 Steve Tyler 2013-08-15 15:07:56 UTC
$ TZ=UTC foo[tab] # this appears to work
in foo
[enter]

in foo
$

Comment 12 Roman Rakus 2013-08-16 11:41:39 UTC
You're right.
Even worse, it only completes using programmable completions - it doesn't complete for binary files in PATH.

Comment 13 Fedora Admin XMLRPC Client 2013-10-07 11:48:02 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 14 Ondrej Oprala 2014-04-01 10:29:31 UTC
Hi and thanks for the report.
This issue is now fixed in bash-4.3, which can be found in rawhide.