Charles.Forsyth20070115bd7846519 years agoHistory
114 lines · 2.0 KB · Text
RawDownload
#!/dis/sh.dis# Plan 9 man script adaptation for Inferno# for more details see the real man(1)load std fils=''cmd=nsec=()S=/mand=0 x=$* # see sh(1) for details about s/$*/$x/.x=`{echo $x|tr A-Z a-z|tr -dc 'a-z0-9_ \012-/'}	# fold case, delete funny chars search=yeswhile {~ $d 0}{	#echo d$d search$search cmd$cmd fils$fils: $"x	if {no $x}{		echo 'Usage: man [-bnSwpf] [0-9] [0-9] ... name1 name2 ...'		exit	}	if{ftest -d $S/${hd $x}}{		sec=($sec ${hd $x}); x=${tl $x};	}{		if{~ ${hd $x} '-n'}{			cmd=n; x=${tl $x};		}{~ ${hd $x} '-w'}{			cmd=w; x=${tl $x};		}{~ ${hd $x} '-b'}{			cmd=b; x=${tl $x};		}{~ ${hd $x} '-p'}{			cmd=p; x=${tl $x};		}{~ ${hd $x} '-s'}{			search=no; x=${tl $x};		}{~ ${hd $x} '-f'}{			search=no; x=${tl $x};			if {ftest -f ${hd $x}}{				fils=(${hd $x});			}{				echo 'man: bad option -f '${hd $x}				exit 'no file'			}		}{			d=1;		}				if{no $x}{			d=1;		}	}}if{no $sec} {	sec=`{ls -pd $S/[0-9]* }} ix=$S/$sec/INDEXif{~ $#x 1} {pat='^'^$x^' '}{pat='^('^`{echo $x | sed 's/ /|/g'}^') '} if{~ $search yes} {	for i in $S/$sec {		if {ftest -f $i/INDEX}{			try=`{grep -i $pat $i/INDEX | sed 's/^[^ ]*//'}			if {! no $try}{				fils=($fils $i/$try)			}		}	}} if{no $fils} {	# nothing in INDEX. try for file or given name	for i in $x {		if{~ $i intro} {i=0intro}		for n in $sec {			try=`{echo $S/$n/$i | tr A-Z a-z}			if {ftest -f $try} {				fils=($fils $try)			}		}	}	if{~ $#fils 0} {		echo 'man: no manual page'		exit 'no man'	}} for i in $fils {	if {~ $i ''}{		#echo bug ignore ''	}{! ftest -f $i}{		echo need:$i	}{		if {~ $cmd n}{			man2txt $i		}{~ $cmd w}{			echo $i		}{~ $cmd p}{			wm/man -f $i		}{~ $cmd b}{			if{~ $i '/man/*/*'}{				x=`{echo $i | sed 's;/man/(.*)/(.*);\1 \2;'}							if{~ ${index 2 $x} 0intro}{					x=(${index 1 $x} intro)				}			}{ x=($i ''); } 			man2txt $i |		 	plumb -i -d edit -a action showdata -a filename '/man/'^${tl $x}^'('^${hd $x}^')' 		}	}	}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t