From 715a0ce04bf7e03730d97c28603d5db1c77d7894 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 26 Nov 2015 18:49:06 +1300 Subject: A little more correct still --- bash/bashrc.d/man.bash | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bash/bashrc.d/man.bash b/bash/bashrc.d/man.bash index 8a6df3ea..b43ee934 100644 --- a/bash/bashrc.d/man.bash +++ b/bash/bashrc.d/man.bash @@ -19,9 +19,10 @@ _man() { # read -a rather than adding each element individually, as it's much faster IFS=/ read -a COMPREPLY -d '' -r < <( - # Do not return dotfiles, and expand empty globs to just nothing + # Do not return dotfiles, give us extended globbing, and expand empty + # globs to just nothing shopt -u dotglob - shopt -s nullglob + shopt -s extglob nullglob # Start an array of pages declare -a pages @@ -32,13 +33,13 @@ _man() { # Iterate through the manual page paths and add every manual page we find for manpath in "${manpaths[@]}" ; do [[ $manpath ]] || continue - pages=("${pages[@]}" "$manpath"/"$section"*/"$word"*) + pages=("${pages[@]}" "$manpath"/"$section"*/"$word"*.[0-9]*) done # Strip paths, .gz suffixes, and finally .
suffixes pages=("${pages[@]##*/}") - pages=("${pages[@]%.gz}") - pages=("${pages[@]%.*}") + pages=("${pages[@]%.@([glx]z|bz2|lzma|Z)}") + pages=("${pages[@]%.[0-9]*}") # Bail out if we ended up with no pages somehow to prevent us from # printing -- cgit v1.2.3