__fish_apropos: assume only /usr/bin/apropos is broken

As discovered in #12062, man-db as installed from brew is not affected
by the "read-only-filesystem" problem what makewhatis suffers from
(though users do need to run "gmandb" once).

Restrict the workaround to the path to macOS's apropos; hopefully
that's stable.

This breaks people who define an alias for apropos; I guess for those
we could check "command -v" instead, but that's weird because the thing
found by type is the actual thing we're gonna execute.  So I'd first
rather want to find out why anyone would override this obscure command.
This commit is contained in:
Johannes Altmanninger
2025-11-15 14:32:26 +01:00
parent c49ff931b1
commit f3f231cf70

View File

@@ -17,6 +17,12 @@ if test (__fish_uname) = Darwin
function __fish_apropos -V dir
# macOS has a read only filesystem where the whatis database should be.
if functions -q apropos || test "$(command -v apropos)" != /usr/bin/apropos
__fish_without_manpager apropos "$argv"
return
end
# The whatis database is non-existent, so apropos tries (and fails) to create it every time,
# which can take seconds.
#
@@ -32,7 +38,7 @@ if test (__fish_uname) = Darwin
set age (path mtime -R -- $whatis)
end
MANPATH="$dir" __fish_without_manpager apropos "$argv"
MANPATH="$dir" __fish_without_manpager /usr/bin/apropos "$argv"
if test $age -ge $max_age
test -d "$dir" || mkdir -m 700 -p $dir