Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: _man - fast searching for glob patterns



On Sep 27,  9:08pm, Andrej Borsenkow wrote:
} Subject: _man - fast searching for glob patterns
}
} while read manpage dummy
}   if [[ $manpage == $our-search-pattern ]]
}    ...
} done < $mandb-file
} 
} needs a considerable amount of time (10-15 seconds here).

On Sep 27,  6:17pm, Zefram wrote:
} Subject: Re: _man - fast searching for glob patterns
}
} Better read the index file once, and cache it in an associative array.

Check out the "mapfile" module.

zmodload mapfile
if [[ -f /usr/man/mandb ]]
then
  allpages=(${"${(f)mapfile[/usr/man/mandb]}"%% *})
  firstmatchingpage=$allpages[(r)$our-search-pattern]
  # ... etc. ...
fi

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author