diff --git a/bash_completion b/bash_completion index 570623eb..5967ba87 100644 --- a/bash_completion +++ b/bash_completion @@ -167,6 +167,8 @@ complete -b builtin have() { unset -v have + # Completions for system administrator commands are installed as well in + # case completion is attempted via `sudo command ...'. PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null && have="yes" } diff --git a/test/config/bashrc b/test/config/bashrc index cc21db7d..ddf06339 100644 --- a/test/config/bashrc +++ b/test/config/bashrc @@ -19,6 +19,9 @@ export INPUTRC=$TESTDIR/config/inputrc [ "$CRON" ] || export TERM=dummy # Ensure enough columns so expect doesn't have to care about line breaks stty columns 150 + # Also test completions of system administrator commands, which are + # installed via the same PATH expansion in `bash_completion.have()' +export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin # Make sure default settings are in effect unset -v \ diff --git a/test/lib/library.exp b/test/lib/library.exp index b8fd9f20..c76d9854 100644 --- a/test/lib/library.exp +++ b/test/lib/library.exp @@ -481,10 +481,7 @@ proc assert_no_output {{cmd} {test ""} {prompt /@}} { # @param string $file (optional) File to source/run. Default is # "lib/completions/$cmd.exp". proc assert_source_completions {command {file ""}} { - if { - [is_bash_completion_installed_for $command] && - [assert_bash_type $command] - } { + if {[is_bash_completion_installed_for $command]} { if {[string length $file] == 0} { set file "lib/completions/$command.exp" } @@ -492,7 +489,7 @@ proc assert_source_completions {command {file ""}} { } else { untested $command } -}; # assert_source_completions() +} # Sort list. @@ -502,7 +499,7 @@ proc assert_source_completions {command {file ""}} { # @return list Sort list proc bash_sort {items} { return [split [exec sort << [join $items "\n"]] "\n"] -}; # bash_sort() +} # Get 'known' hostnames. Looks also in ssh's 'known_hosts' files.