http://memo.hirosiki.jp/article/54294582.html
portableじゃないよね。Bourne(not again)Shellで書くべきだ
できたー。
YappoLogs: Gopper - Gopher2.0時代のプラガブルGopher Serverをリリース
http://blog.yappo.jp/yappo/archives/000528.html
のperl版の対抗馬「gobar」。いまgopherを上げるなら、よりライトウェイトなコッチ。
#!/bin/sh
ROOTDIR='/var/net/gobar/doc'
HOSTNAME='your.fqdn'
PORT='70'
read line
line=`\
/bin/echo -n "$line" \
| /bin/sed -e 's/[\x0a\x0d]//g;' \
-e 's/\.\.//g;' \
-e 's/[\|\&\;]//g;' \
-e 's/^\///;' \
-e 's/\/$//;' \
`
cd "$ROOTDIR"
isd=''
if [ -z "$line" ];
then
isd='/'
elif [ -d "$line" ];
then
cd "$line"
isd="/$line/"
elif [ -r "$line" ];
then
case "$line" in
*.txt)
/bin/cat "$line" | /bin/sed -e 's/^\./../;'
/bin/echo '.'
;;
*)
/bin/cat "$line"
;;
esac
exit
else
# ERROR
isd='/'
fi
bkIFS="$IFS"
IFS='
'
isd=`/bin/echo -n "$isd" | /bin/sed -e 's/^\.\///;'`
for i in `/bin/ls -1`
do
if [ ! -r "$i" ];
then
continue
fi
if [ -d "$i" ];
then
ftype='1'
else
case "$i" in
*.txt)
ftype='0'
;;
*)
ftype='9'
;;
esac
fi
/bin/echo "$ftype$i $isd$i $HOSTNAME $PORT"
done
/bin/echo '.'
元ファイル:gobar.sh
って、どこがportableなんだよ…。あと、ひとつ致命的な問題があるが、それは正直「どうでもええやんけ」と思っているのでいいや。
あとHTMLに「h」のマークを付けるのってRFC的にはどうなんだ…>iYappoの人。