Add more paths to search for bash completion

This commit is contained in:
Thomas Scholtes 2014-04-16 23:53:45 +02:00
parent 8877d2a5c2
commit 151b451c33

View file

@ -1462,12 +1462,17 @@ default_commands.append(config_cmd)
def print_completion(*args):
for line in completion_script(default_commands + plugins.commands()):
print(line, end='')
if not (os.path.isfile(u'/etc/bash_completion') or
os.path.isfile(u'/usr/share/bash-completion/bash_completion') or
os.path.isfile(u'/usr/share/local/bash-completion/bash_completion')):
if not any(map(os.path.isfile, BASH_COMPLETION_PATHS)):
log.warn(u'Warning: Unable to find the bash-completion package. '
u'Command line completion might not work.')
BASH_COMPLETION_PATHS = [
u'/etc/bash_completion',
u'/usr/share/bash-completion/bash_completion',
u'/usr/share/local/bash-completion/bash_completion',
u'/opt/local/share/bash-completion/bash_completion',
]
def completion_script(commands):
"""Yield the full completion shell script as strings.