diff --git a/CHANGES b/CHANGES index 6c0b4ed6..1a28407a 100644 --- a/CHANGES +++ b/CHANGES @@ -14,8 +14,8 @@ bash-completion (2.x) * Add *.gif (Alioth: #312512), *.m2t (Alioth: #312770), *.3gpp, *.3gpp2, and *.awb to mplayer filename completions. * Add "short" tarball extensions to unxz, unlzma etc completions. - * Improve /etc/init.d/*, ipmitool, jar, mencoder, mkdir, mplayer, povray, - rpmbuild, sqlite3, wodim, and general help parsing completions. + * Improve /etc/init.d/*, ipmitool, jar, man, mencoder, mkdir, mplayer, + povray, rpmbuild, sqlite3, wodim, and general help parsing completions. * Fix p4 and povray completions (Alioth: #312625). * Add *.xsd, *.xsl, *.rng, and *.wsdl to xmllint filename completions. * Recognize rpm query mode based on the --file, --group, --package, and diff --git a/completions/man b/completions/man index a3360b2e..0cf3e2ed 100644 --- a/completions/man +++ b/completions/man @@ -11,7 +11,7 @@ _man() mansect="@([0-9lnp]|[0-9][px]|3pm)" COMPREPLY=() - _get_comp_words_by_ref cur prev + _get_comp_words_by_ref -n : cur prev if [[ "$prev" == -l ]]; then _filedir $manext @@ -66,6 +66,7 @@ _man() done fi + __ltrim_colon_completions "$cur" return 0 } [ $USERLAND = GNU -o $UNAME = Darwin \ diff --git a/test/fixtures/man/man1/bar.1.bz2 b/test/fixtures/man/man1/bar.1.bz2 new file mode 100644 index 00000000..e69de29b diff --git a/test/fixtures/man/man1/foo.1 b/test/fixtures/man/man1/foo.1 new file mode 100644 index 00000000..e69de29b diff --git a/test/fixtures/man/man3/Bash::Completion.3pm.gz b/test/fixtures/man/man3/Bash::Completion.3pm.gz new file mode 100644 index 00000000..e69de29b diff --git a/test/lib/completions/man.exp b/test/lib/completions/man.exp index 47a6575f..e0056ca2 100644 --- a/test/lib/completions/man.exp +++ b/test/lib/completions/man.exp @@ -1,4 +1,5 @@ proc setup {} { + assert_bash_exec {export MANPATH=$TESTDIR/fixtures/man} save_env } @@ -11,7 +12,19 @@ proc teardown {} { setup -assert_complete_any "man man" +assert_complete "bar" "man b" + + +sync_after_int + + +assert_complete "fixtures/man/man1/foo.1" "man fixtures/man/man1/f" + + +sync_after_int + + +assert_complete "Bash::Completion" "man Bash::C" sync_after_int