laba-2kc@web-2c.berkeley.edu (Sang Yup Kim) (08/13/89)
Here's a man "server" in rexx. To use it, install it (set the first few assignments to the proper directories/etc), and then when you call it, the usage is: man -e file It automatically assumes a .doc. You can set it to assume any other thing as an extension if you want. Please send comments/suggestions/etc to: Na Choon Piaw laba-2kc@web.berkeley.edu /* subject to change very soon */ ---------------------------------------- cut here ------------------------- /* Copyright 1989 by Na Choon Piaw */ /* Freely distributable provided this header remains intact */ /* man -- show manual page (originally on Rexx disk, heavily modified) */ /* usage: man [ -e | -m ] document */ /* NOTE: You must have rexx, rexxarplib installed, and arp.library */ /* to run this program */ /* trace ?R */ /* first for the defines - put your own locations for env, more, and docs */ /* directory here */ more = 'sys:utilities/more' env = 'ram:env/' docsdir = 'docs:' parse arg x y /* check for the -e and -m option */ if x = '-e' | x = '-E' then manuse = getenv('editor') else if x = '-m' | x = '-M' then manuse = more else do drop manuse y = x end /* taken care of potential options */ x = strip(y, 'B') shell command /* has a file been named? */ if x = '' then do x = getfile(0, 0, docsdir,'', 'Manual search') if x = '' then exit 0 if exists(x) then call openfile(x, manuse) else say x 'does not exists' exit 0 end /* user has selected a file */ x = docsdir || x || '.doc' if exists(x) then call openfile(x, manuse) else say 'No manual entry for' substr(x,6,length(x)-9) exit 0 /* open the file using y as a program and x as the file. */ openfile: procedure expose env more arg x,y if y = manuse then /* user has not selected option */ do result = request(0, 0, 'More or Edit',,'More','Edit') if result = 'OKAY' then more x else do ed = getenv('editor') 'run' ed x end /* else */ end /* then */ else y x exit 0 /* getenv (1.3 version) */ /* other versions just strip this procedure and do a direct call thru */ /* rexxarplib. */ getenv: procedure expose env more arg y z = env || y if exists(z) then do call open(f, z, 'R') retval = readln(f) call close(f) return retval end else return more