]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/thesaurus
cat: remove stupid long cast
[plan9front.git] / rc / bin / thesaurus
1 #!/bin/rc
2
3 hget 'http://thesaurus.reference.com/search?q='^$1 |
4         htmlfmt -l 1000 |
5         sed -n '/^Main Entry:/,/^Source/ {
6                 /^Source/ q
7                 /^[A-Z].*:/ {
8                         N
9                         s/\n/   /g
10                 }
11                 p
12         }' | awk -F', ' '{
13                 if(length($0)<=70){
14                         print
15                         next
16                 }
17                 l = 0
18                 for(i = 1; i < NF; i++){
19                         printf "%s ", $i
20                         l += length($i)+1
21                         if(l > 70){
22                                 printf "\n\t\t"
23                                 l = 2*ENVIRON["tabstop"]
24                         }
25                 }
26                 if(l>0)
27                         printf "\n"
28                 next
29         }'