Skip to Content.
Sympa Menu

baslinux - Re: [BL] Fixed My Man Script (take two)

baslinux AT lists.ibiblio.org

Subject: Baslinux mailing list

List archive

Chronological Thread  
  • From: Karolis Lyvens <karolisl AT gmail.com>
  • To: lforrestster AT gmail.com, baslinux AT lists.ibiblio.org
  • Subject: Re: [BL] Fixed My Man Script (take two)
  • Date: Sun, 31 Dec 2006 13:11:37 +0200

On Sat, Dec 30, 2006 at 08:32:17PM +0000, Lee Forrest wrote:
> Let's try again, with another fix and an improvement:
>
> (I neglected to include full paths to all the files referred
> to.)
>
> On Sat, Dec 30, 2006 at 07:35:52PM +0000, Lee Forrest wrote:
>
> ----------
> #!/bin/sh
>
> #for plain text man pages gzipped in /usr/man
>
> # put your favorite editor here
>
> ed=/usr/bin/nvi
>
> # assign first arg to man on the commandline to the variable
> # 'file'
# Error checking here would help:
if test -n $1; then
# Or, alternately:
#if [ -n $1 ]; then
file=$1
fi
>
> # test if there isn't any such manpage, and if that's the
> # case, say so and exit with an error code (1)
>
> if ! test -s /usr/man/${file}.gz
> then echo "No Such Manpage"
> exit 1
> fi
>
> # see if /usr/man/${1}.gz is a symlink.

>
> if test -h /usr/man/${file}.gz
>
> # if it is, extract the name of the manpage, minus the ".gz"
> # and assign it to $file
>
> then file=`ls -l /usr/man/${file}.gz | sed -n 's/^\(.*
> \)\(.*\)\(.gz$\)/\2/p'`

Why the "ls -l"? The regexp doesn't use any information from "ls -l"
anyway. The same result could be achieved by a much shorter regexp:

---
then file=`ls /usr/man/${file}.gz | sed 's/\(.*\)\.gz$/\1/'`
---

Both substitutions with sed leave pathname intact, which would
expand the later "gunzip /usr/man/${file}.gz" (when $1 == ash) to
"/usr/man/usr/man/ash.gz". It helps to know some other utilities (that
are included in busybox):

---
then file=`basename /usr/man/${file}.gz .gz`
---

> fi
>
> gunzip /usr/man/${file}.gz &&
> $ed /usr/man/${file} &&
> gzip /usr/man/${file}
>
> ----------------
>
> Lee :-/
>
> --
> BasicLinux: Small is Beautiful
> http://www.basiclinux.com.ru
>
>
> -----------------------
> BasicLinux mailing list
> -----------------------
> http://www.basiclinux.com.ru
> http://www.ibiblio.org/pub/linux/distributions/baslinux/
> ------------------------------------
> To exit, send subject=unsubscribe to
> baslinux-request AT lists.ibiblio.org




Archive powered by MHonArc 2.6.24.

Top of Page