Fix _filedir error message on bash-3

In case of `sudo cmd', _filedir might be triggered for a cmd not having a
complete command, hence `complete -p cmd' could yield an error. (Alioth
This commit is contained in:
Freddy Vulto 2010-08-18 23:01:26 +02:00
parent 9b97b40c4a
commit b867bcd64f
3 changed files with 9 additions and 1 deletions

View File

@ -17,6 +17,7 @@ bash-completion (2.x)
[ Freddy Vulto ] [ Freddy Vulto ]
* Added _tilde(), fix ~username completion (Alioth: #312613, Debian: #587095) * Added _tilde(), fix ~username completion (Alioth: #312613, Debian: #587095)
* Speed up `compopt' availability detection * Speed up `compopt' availability detection
* Fix _filedir `-o filenames' detection on bash-3 (Alioth: #312646)
[ Anton Khirnov ] [ Anton Khirnov ]
* Improve mplayer and mencoder completions. * Improve mplayer and mencoder completions.

View File

@ -647,7 +647,8 @@ _filedir()
# Is `-o filenames' set? # Is `-o filenames' set?
[[ ( [[ (
${COMP_WORDS[0]} && ${COMP_WORDS[0]} &&
"$(complete -p ${COMP_WORDS[0]})" == *"-o filenames"* "$(complete -p ${COMP_WORDS[0]} &>/dev/null)" == \
*"-o filenames"*
) ]] || { ) ]] || {
# No, `-o filenames' isn't set; # No, `-o filenames' isn't set;
# Emulate `-o filenames' # Emulate `-o filenames'

View File

@ -17,4 +17,10 @@ assert_complete "fixtures/shared/default/foo.d/" "sudo cd fixtures/shared/defaul
sync_after_int sync_after_int
assert_complete "fixtures/" "sudo sh fix"
sync_after_int
teardown teardown