#!/bin/rc rfork en foundit='no' if (~ $#* 0) { echo 'usage: wiki [-l | article [article...]]' >[1=2] exit usage } if (! test -f /mnt/wiki/new) 9fs wiki || exit mount if (~ $1 '-l') { cd /mnt/wiki for (i in */index.html) {basename -d $i} exit } # Check if the argument list is an unescaped page title. name=`{echo $"* | tr 'A-Z ' 'a-z_'} if (test -r /mnt/wiki/$name/index.txt) cat /mnt/wiki/$name/index.txt && exit # Check if the argument list matches a page with -s for spaces. name=`{echo $"* | tr 'A-Z ' 'a-z\-'} if (test -r /mnt/wiki/$name/index.txt) cat /mnt/wiki/$name/index.txt && exit # Check if each argument is a page title. for (i in $*) { name=`{echo $i | tr 'A-Z ' 'a-z_'} if (test -r /mnt/wiki/$name/index.txt) cat /mnt/wiki/$name/index.txt && foundit='yes' if not echo 'No article named '$i' could be found.' >[1=2] } # All our earlier attempts have failed. if(~ $foundit 'no') { echo 'No article with that name could be found.' >[1=2] exit badname }