Plan 9 from Bell Labs’s /usr/web/sources/contrib/cinap_lenrek/gophe.rc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc

root=/usr/web
server=9hal.ath.cx
port=70

fn gls {
r='{f=$10
sub("^'^$"root^'", "", f)
b=$10
sub("^.*/", "", b)
print "'
x='"b"	"f"	'^$"server^'	'^$"port^'"
next
}'
a='
/^d/'^$"r^1^$"x^'
/\.gph$/'^$"r^1^$"x^'
/README$/'^$"r^0^$"x^'
/\.Z$/'^$"r^5^$"x^'
/\.awk$/'^$"r^0^$"x^'
/\.c$/'^$"r^0^$"x^'
/\.gif$/'^$"r^g^$"x^'
/\.h$/'^$"r^0^$"x^'
/\.html$/'^$"r^h^$"x^'
/\.man$/'^$"r^0^$"x^'
/\.mod$/'^$"r^s^$"x^'
/\.mp3$/'^$"r^s^$"x^'
/\.ms$/'^$"r^0^$"x^'
/\.ogg$/'^$"r^s^$"x^'
/\.pdf$/'^$"r^d^$"x^'
/\.ps$/'^$"r^d^$"x^'
/\.rc$/'^$"r^0^$"x^'
/\.s$/'^$"r^0^$"x^'
/\.tar$/'^$"r^5^$"x^'
/\.tex$/'^$"r^0^$"x^'
/\.tgz$/'^$"r^5^$"x^'
/\.troff$/'^$"r^0^$"x^'
/\.txt$/'^$"r^0^$"x^'
/\.wav$/'^$"r^s^$"x^'
/\.zip$/'^$"r^5^$"x^'
/mkfile$/'^$"r^0^$"x^'
'^$"r^9^$"x
ls -l $1 | awk $"a | sed 's/$/
/g'
}

fn gph {
	sed '
s/\|server\|[^\|\]]+\]$/|'^$"server^'|'^$"port^']/;
s/^\[//g; s/]$//g; s/(.)\|/\1/;
s/\|/	/g; s/$/
/g;' < $1
}

r=`{read | sed 's/
//g; s/\.\.//g; s!//!!g;'}

if(~ $"r ''){
	r=$"root
}
if not {
	r=$"root^$"r
}

if(test -d $"r){
	if(test -r $"r/index.gph){
		gph $"r/index.gph
	}
	if not {
		gls $"r
	}
}
if not {
	if(test -r $"r) {
		if(~ $"r *.gph){
			gph $"r
		}
		if not {
			cat $"r
			exit
		}
	}
	if not {
		echo '3"'^$"r^'" not found	error.file	error.host	0
'
	}
}
echo '.
'


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].