Bug 1495055

Summary: 'man' completion not working when MANPATH contains colons ":"
Product: [Fedora] Fedora Reporter: Viorel Tabara <viorel.tabara>
Component: bash-completionAssignee: Siteshwar Vashisht <svashisht>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 26CC: fatkasuvayu, kdudka, mrunge, ooprala, rjones, sheltren, tmz
Target Milestone: ---Keywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: bash-completion-2.7-4.fc28 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-03-30 12:53:54 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 Viorel Tabara 2017-09-25 04:42:59 UTC
Description of problem:

'man <keyword> <TAB> <TAB>' shows no options.

I came across this after installing python3-sphinx which requires Lmod, and 
which in turn sets MANPATH to "/usr/share/lmod/lmod/share/man::".


Version-Release number of selected component (if applicable):

bash-completion-2.6-1.fc26.noarch


How reproducible:

Always.


Steps to Reproduce:
1. Install Lmod package or set MANPATH to "blah:", or ":blah", or "blah::".
2. Type in "man dnf <TAB> <TAB>"
3. Unset MANPATH.
4. Repeat #2.

Actual results:

No output on #2, and correct output on #4.

Expected results:

A list of options e.g.:

omiday ~ $ man dnf
dnf            dnf.plugin.builddep        dnf.plugin.debug              dnf.plugin.generate_completion_cache  dnf.plugin.repograph   dnf.plugin.system-upgrade
dnf.automatic  dnf.plugin.config_manager  dnf.plugin.debuginfo-install  dnf.plugin.needs_restarting           dnf.plugin.repomanage  
dnf.conf       dnf.plugin.copr            dnf.plugin.download           dnf.plugin.repoclosure                dnf.plugin.reposync    
 

Additional info:

The following seems to fix it:

    --- a/usr/share/bash-completion/completions/man
    +++ b/usr/share/bash-completion/completions/man
    @@ -53,10 +53,7 @@ _man()
            return
        fi

    -    local manpath="$MANPATH"
    -    [[ -z $manpath ]] && \
    -        manpath=$( manpath 2>/dev/null || command man -w 2>/dev/null )
    -    [[ -z $manpath ]] && manpath="/usr/share/man:/usr/local/share/man"
    +    local manpath=$( manpath 2>/dev/null || command man -w 2>/dev/null )

        # determine manual section to search
        local sect

Comment 2 Richard W.M. Jones 2017-12-05 18:59:01 UTC
Can confirm this happens with bash-completion-2.7-2.fc28.noarch.

Unfortunately this affects me because ‘Lmod’ (something to do with
Lua) sets the MANPATH variable (/usr/share/lmod/lmod/share/man::)
for some reason, possibly a bug, but that breaks man completions
on the whole server.

Comment 3 Suvayu 2018-03-05 12:58:03 UTC
Any reason the fix from upstream hasn't been included?  It's been 5 months.

Comment 4 Kamil Dudka 2018-03-05 16:32:59 UTC
Not that I know of.  I believe that Siteshwar will have a look once he is back from his trip.  Thanks for the reminder!

Comment 5 Fedora Update System 2018-03-14 15:26:52 UTC
bash-completion-2.7-4.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-d3744aeca4

Comment 6 Fedora Update System 2018-03-15 13:29:59 UTC
bash-completion-2.7-4.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-d3744aeca4

Comment 7 Fedora Update System 2018-03-30 12:53:54 UTC
bash-completion-2.7-4.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.

Comment 8 Todd Zullinger 2018-05-17 17:05:10 UTC
Can this fix be applied to f27 as well, since it has 6+ months until EOL?  Having man page completions broken gives bash-completion a bad name.

I stumbled across this today. I initially thought it was due to #1545264, until I started digging further and then I saw it was fixed for f28 and rawhide but not f27.