diff options
| author | Igor Murzov <e-mail@date.by> | 2011-09-26 00:22:05 +0400 |
|---|---|---|
| committer | Igor Murzov <e-mail@date.by> | 2011-09-30 22:21:47 +0400 |
| commit | 5051b1787ad384b342aba2f00a56130c25b6fc7f (patch) | |
| tree | 5efb58e8dd3a038a844670e748a83782f271304d /bash_completion | |
| parent | b9a5f508e2b2ed9e4a06b2adae254debcc4a749a (diff) | |
| download | bash-completion-5051b1787ad384b342aba2f00a56130c25b6fc7f.tar.gz | |
_command_offset: Restore compopts used by called command.
This fixes completions that rely on their compopts, most notably mount(8).
Fixes bash-completion bug #313183.
Diffstat (limited to 'bash_completion')
| -rw-r--r-- | bash_completion | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/bash_completion b/bash_completion index 556d83fd..cdd2fe96 100644 --- a/bash_completion +++ b/bash_completion @@ -1543,8 +1543,7 @@ _command() # A meta-command completion function for commands like sudo(8), which need to # first complete on a command, then complete according to that command's own -# completion definition - currently not quite foolproof (e.g. mount and umount -# don't work properly), but still quite useful. +# completion definition. # _command_offset() { @@ -1606,18 +1605,18 @@ _command_offset() $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" fi - # remove any \: generated by a command that doesn't - # default to filenames or dirnames (e.g. sudo chown) - # FIXME: I'm pretty sure this does not work! - if [ "${cspec#*-o }" != "$cspec" ]; then - cspec=${cspec#*-o } - cspec=${cspec%% *} - if [[ "$cspec" != @(dir|file)names ]]; then - COMPREPLY=("${COMPREPLY[@]//\\\\:/:}") - else - compopt -o filenames + # restore initial compopts + local opt t + while true; do + # FIXME: should we take "+o opt" into account? + t=${cspec#*-o } + if [ "$t" == "$cspec" ]; then + break fi - fi + opt=${t%% *} + compopt -o $opt + cspec=${t#$opt} + done else cspec=${cspec#complete} cspec=${cspec%%$compcmd} |
