13 translate_grepsafe() {
14 # The regexp below is supposed to be [\[\].*$^\\], but sed sucks
15 # and doesn't support simple and intuitive escaping and we have to
16 # do it the hard way with the collations [.[.] and [.].] standing
17 # for [ and ], respectively.
18 sed 's:^[ \t]*\(.*\)[ \t]*$:\1:; s:[[.[.][.].].*$^\\]:\\&:g'
22 while test $# -ge 1; do
31 read section tocompl << EOF
34 if test "$tocompl" = ""; then
40 tocompl=`echo "$tocompl" | translate_grepsafe`
59 if test "x$action" = x; then
60 echo 2>&1 "Usage: $prog [-icase] [-mid] (-complete what|-mkusercache|-mksyscache)"
66 sed 's:^.*/\([^/]*\.[0-9].*\)$:\1:p; d'
70 sed 's:^\(.*\)\.[0-9].*$:\1:p; d'
74 if test "$tocompl" = "" -a "$section" = ""; then
77 if test "$section" = ""; then
80 grep $icase "$linebeg$tocompl.*\.$section"
85 if test "x$ION_MANPATH" != "x"; then
87 elif test "x$MANPATH" != "x"; then
90 mpprog=`which manpath`
91 if test "x$mpprog" = x; then
92 echo "Please set MANPATH, ION_MANPATH or put 'manpath' on PATH" > /dev/stderr
98 for p in `echo "$mpath"|tr : '\n'`; do
99 find "$p" -type f -o -type l | filterpath
106 if test "x$HOME" != x; then
107 usercache="$HOME/.ion3/mancache"
110 syscache="@VARDIR@/mancache"
114 if test "x$usercache" != x -a -f "$usercache"; then
115 cachefile="$usercache"
118 if test -f "$syscache"; then
119 cachefile="$syscache"
122 # Empty "common part" of completions.
125 if test "x$cachefile" != x; then
126 grepper < "$cachefile" | filtersect
128 scan | grepper | filtersect
132 if test "x$usercache" != x; then
135 echo >&2 "\$HOME not set."