10 translate_grepsafe() {
11 # The regexp below is supposed to be [\[\].*$^\\], but sed sucks
12 # and doesn't support simple and intuitive escaping and we have to
13 # do it the hard way with the collations [.[.] and [.].] standing
14 # for [ and ], respectively.
15 sed 's:^[ \t]*\(.*\)[ \t]*$:\1:; s:[[.[.][.].].*$^\\]:\\&:g'
20 read section tocompl << EOF
23 if test "$tocompl" = ""; then
29 tocompl=`echo "$tocompl" | translate_grepsafe`
40 if test "x$action" = x; then
41 echo 2>&1 "Usage: $0 (-complete what|-mkusercache|-mksyscache)"
47 sed 's:^.*/\([^/]*\.[0-9].*\)$:\1:p; d'
51 sed 's:^\(.*\)\.[0-9].*$:\1:p; d'
55 if test "$tocompl" = "" -a "$section" = ""; then
58 if test "$section" = ""; then
61 grep "^$tocompl.*\.$section"
66 if test "x$ION_MANPATH" != "x"; then
68 elif test "x$MANPATH" != "x"; then
71 mpprog=`which manpath`
72 if test "x$mpprog" = x; then
73 echo "Please set MANPATH, ION_MANPATH or put 'manpath' on PATH" > /dev/stderr
79 for p in `echo "$mpath"|tr : '\n'`; do
80 find "$p" -type f -o -type l | filterpath
87 if test "x$HOME" != x; then
88 usercache="$HOME/.ion3/mancache"
91 syscache="@VARDIR@/mancache"
95 if test "x$usercache" != x -a -f "$usercache"; then
96 cachefile="$usercache"
99 if test -f "$syscache"; then
100 cachefile="$syscache"
103 # Empty "common part" of completions.
106 if test "x$cachefile" != x; then
107 grepper < "$cachefile" | filtersect
109 scan | grepper | filtersect
113 if test "x$usercache" != x; then
116 echo >&2 "\$HOME not set."