diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2015-11-26 18:49:06 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2015-11-26 18:49:06 +1300 |
commit | 715a0ce04bf7e03730d97c28603d5db1c77d7894 (patch) | |
tree | 4f5a25e66ae29a97ca0e685273f54819aa0cb6b6 /bash/bashrc.d/man.bash | |
parent | Fix/flesh out the comments a bit (diff) | |
download | dotfiles-715a0ce04bf7e03730d97c28603d5db1c77d7894.tar.gz dotfiles-715a0ce04bf7e03730d97c28603d5db1c77d7894.zip |
A little more correct still
Diffstat (limited to 'bash/bashrc.d/man.bash')
-rw-r--r-- | bash/bashrc.d/man.bash | 11 |
1 files 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 .<section> 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 |