Run makewhatis in the background

In the new __fish_apropos, makewhatis is run explicitly to generate the
whatis database. However this can be a little slow. Run it in the
background, after the apropos call completes so as to avoid a weird
race.

This means that descriptions may not be available the first time the
user invokes it, but that's better than appearing to hang for a while.
This commit is contained in:
ridiculousfish 2020-10-03 17:08:13 -07:00
parent a6a0d43c9c
commit a6686ca310

View file

@ -27,12 +27,12 @@ function __fish_apropos
set age (math (date +%s) - (stat -f %m $db))
end
if test $age -ge $max_age
echo "making cache $age $max_age"
mkdir -m 700 -p $cache
/usr/libexec/makewhatis -o $db (man --path | string split :) >/dev/null 2>&1
end
MANPATH="$cache" apropos $argv
if test $age -ge $max_age
mkdir -m 700 -p $cache
/usr/libexec/makewhatis -o $db (man --path | string split :) >/dev/null 2>&1 </dev/null &
end
else
apropos $argv
end