This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

man, less (more), groff, and which


It seems there are a lot a questions about man in here.  Perhaps if I share what I did, some of you may find it useful.  When I first loaded cygwin (b17.1), I too felt crippled without man, more, vi, which, etc..  For vi, I'm using vim 4.6, works great.  That wasn't the hard part.

For man, I built groff-1.10 from prep.ai.mit.edu will only minor difficulties and less (version and source unknown - however, I found it on one of the pages linked from the Cygnus Gnu-win32 home page).  Then I put a (quite crude but functional) script in /usr/bin/man as follows:

--- cut ---
#! /bin/sh

#  Filename : man
#  Author   : Steve Bowman
#  Created  : 970323N
#  Modified : 970724R


#  crude - the following are known bugs/omissions:
#	doesn't handle multiple arguments (use shift)
#	doesn't break search when file found
#	doesn't check extension match
#	doesn't handle pager environment
#	doesn't handle flag to alter search path without resetting MANPATH
#	assumes groff and less are in PATH


if [ $# -eq 0 ]; then
    echo "Usage: man <manpage>"
    exit 1
fi

if [ x$MANPATH = x ]; then
    MANPATH=/usr/man:/usr/gnuwin32/b18/man
fi

for i in `echo $MANPATH | sed s/:/\ /g`; do
    if [ -d $i ]; then
	cd $i
	if [ -f man?/$1.1 ]; then
	    if [ $? -eq 0 ]; then
		groff -man -Tascii -Wall man?/$1.? | less
	    fi
	fi
    fi
done

exit 0
--- cut ---

And finally, to launch it I put a function in /etc/profile:

man () { sh /usr/bin/man $@; }

Since that version of bash wouldn't recognize /usr/bin/man as executable.  I don't know if that's still a problem or not.

'Which' I solved the same way as man, except no more supporting packages were required.

/usr/bin/which:

---  cut  ---
#! /bin/sh

#  Filename : which
#  Author   : Steve Bowman
#  Created  : 970323N
#  Modified : 970724R


#  should check for aliases


if [ $# -eq 0 ]; then
    echo "Usage: which <command>"
    exit 1
fi

if [ x$PATH = x ]; then
    echo "Error: No PATH"
    exit 1
fi

for i in `echo $PATH | sed s/:/\ /g`; do
    if [ -f $i/$1.exe ]; then
	echo $i/$1.exe
	exit 0
    elif [ -f $i/$1 ]; then
	echo $i/$1
	exit 0
    fi
done

echo "${1}: not found"

exit 1
---  cut  ---

and added:

which () { sh /usr/bin/which $@; }

to /etc/profile.

Real, compiled programs would be better, but not having them is no reason to do without.

Steve Bowman

P.S. Platform: win95, currently running gnuwin32 beta 18.

P.P.S. I don't recall the details of what I had to do to build groff, but if anyone is desperate, I'll rebuild it and figure it out again.  No promises on how soon I can get back to this mailing list, though.

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]