Plan 9 from Bell Labs’s /usr/web/sources/contrib/arisawa/misc/fact

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


#!/bin/rc
#
#	fact is a tool to manage factotum. 
#
usage='usage: fact [-adl]'
fn addkey {
	echo adding to $1
	cat $1
	echo '# put data and ctl-D'
	read -m >/$1
}

fn delkey {
	echo deleting from $1
	sed 's/key/delkey/g;s/!.*?//g' < $1
	echo '# send and ctl-D'
	read -m > $1
}

ctl=()
f=(/mnt /mnt/term/mnt)^/factotum/ctl
if(test -w $f(2)) ctl=$f(2)
if(test -w $f(1)) ctl=$f(1)

while(~ $1 -*){
	switch($1){
	case	-d
		delkey $ctl
		exit
	case	-d1
		delkey $f(1)
		exit
	case	-d2
		delkey $f(2)
		exit
	case -a
		addkey $ctl
		exit
	case -a1
		addkey $f(1)
		exit
	case -a2
		addkey $f(2)
		exit
	case -l
		f=(/mnt /mnt/term/mnt)^/factotum
		for (x in $f)
			if(test -e $x) ls -l $x
		exit
	case -*
		echo $usage
		exit usage
	}	
	shift
}

for (x in $f)
	if(test -w $x){
		ls -l $x
		cat $x
	}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.