blob: ebd13f4f464aadb7ae5d4a12a1a5ed5e4d58d364 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#!/dis/sh.dis
# Plan 9 man script adaptation for Inferno
# for more details see the real man(1)
load std
fils=''
cmd=n
sec=()
S=/man
d=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=yes
while {~ $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/INDEX
if{~ $#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}^')'
}
}
}
|