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

Re: PATCH: _man - small fix for manpages without section number suffix



> >
> > Our version of CDE installs manpages without section suffix (i.e.
> > /usr/dt/man/man1/dtsession.Z instead of dtsession.1.Z).
> >
> > Anybody objects to the following patch?
>
> Thinking about it - any reason to check for specific suffix at all? What
> else can live in manpath directories?

How about this: simply check for files with a `.' in, and only do more
powerful processing when stripping suffixes.  The processing is: attempt to
strip a known compression suffix (this is the only place where these need
to go now), then attempt to strip the _minimum_ suffix beginning with a dot
and a number (separating these into separate expansions means they always
both get tried --- btw extendedglob didn't seem to get set for that `##' in
the old version).  This handles cases like Solaris's POSIX.1.5 (i.e. the
manual entry for POSIX.1 in man5).  If Andrej has entries with similar
names like POSIX.1.Z, then we're out of luck and will have to resort to
some extra processing to decide the current system's format.

Index: Completion/User/_man
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_man,v
retrieving revision 1.4
diff -u -r1.4 _man
--- Completion/User/_man	2000/05/31 09:27:52	1.4
+++ Completion/User/_man	2000/07/19 08:54:53
@@ -30,13 +30,16 @@
 mrd=(${^manpath/\%L/${LANG:-En_US.ASCII}}/mandb(N))
 if [[ $words[2] = (<->*|1M|l|n) ]]; then
   rep=(
-  $manpath/(sman|man|cat)${words[2]}/${~approx}$PREFIX${~star}$SUFFIX.<->*(N:t) )
+  $manpath/(sman|man|cat)${words[2]}/${~approx}$PREFIX${~star}$SUFFIX.*(N:t) )
   (($#mrd)) && rep[$#rep+1]=($(awk "\$2 == \"$words[2]\" {print \$1}" $mrd))
 else
-  rep=( $manpath/(sman|man|cat)*/${~approx}$PREFIX${~star}$SUFFIX.<->*(N:t) )
+  rep=( $manpath/(sman|man|cat)*/${~approx}$PREFIX${~star}$SUFFIX.*(N:t) )
   (($#mrd)) && rep[$#rep+1]=($(awk '{print $1}' $mrd))
 fi
 
 
+# Remove any compression suffix, then remove the minimum possible string
+# beginning with .<->: that handles problem cases like files called
+# `POSIX.1.5'.
 (( $#rep )) && _wanted manuals expl 'manual page' \
-    compadd - ${rep%%.[^.]##(.gz|.bz2|)}
+    compadd - ${${rep%%.(bz2|z|gz|Z)}%.<->*}


-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070



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