diff options
author | Wolfram Schneider <wosch@FreeBSD.org> | 2024-01-13 16:16:55 +0000 |
---|---|---|
committer | Wolfram Schneider <wosch@FreeBSD.org> | 2024-01-13 16:16:55 +0000 |
commit | e3c7b76fa8105929ae9a785e5ffc44274b1b0a81 (patch) | |
tree | 3b34eeb7f7734f73351ddd55f3d49612dc85928e /usr.bin/man | |
parent | c8328f1a7b6ea59951e2ea2c1a9a4aa10020c8c5 (diff) | |
download | src-e3c7b76fa8105929ae9a785e5ffc44274b1b0a81.tar.gz src-e3c7b76fa8105929ae9a785e5ffc44274b1b0a81.zip |
Diffstat (limited to 'usr.bin/man')
-rwxr-xr-x | usr.bin/man/man.sh | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh index 7e2151295ba7..777726f880db 100755 --- a/usr.bin/man/man.sh +++ b/usr.bin/man/man.sh @@ -191,7 +191,9 @@ decho() { } # Usage: exists glob -# Returns true if glob resolves to a real file. +# +# Returns true if glob resolves to a real file and store the first +# found filename in the variable $found exists() { local IFS @@ -201,14 +203,16 @@ exists() { # Use some globbing tricks in the shell to determine if a file # exists or not. set +f - set -- "$1" $1 + for file in "$1"* + do + if [ -r "$file" ]; then + found="$file" + set -f + return 0 + fi + done set -f - if [ "$1" != "$2" -a -r "$2" ]; then - found="$2" - return 0 - fi - return 1 } @@ -230,10 +234,10 @@ find_file() { fi decho " Searching directory $manroot" 2 - mann="$manroot/$4.$2*" - man0="$manroot/$4.0*" - catn="$catroot/$4.$2*" - cat0="$catroot/$4.0*" + mann="$manroot/$4.$2" + man0="$manroot/$4.0" + catn="$catroot/$4.$2" + cat0="$catroot/$4.0" # This is the behavior as seen by the original man utility. # Let's not change that which doesn't seem broken. @@ -313,7 +317,7 @@ man_check_for_so() { .so*) trim "${line#.so}" decho "$manpage includes $tstr" # Glob and check for the file. - if ! check_man "$path/$tstr*" ""; then + if ! check_man "$path/$tstr" ""; then decho " Unable to find $tstr" return 1 fi |