9front - general discussion about 9front
 help / color / mirror / Atom feed
From: arisawa <arisawa@ar.aichi-u.ac.jp>
To: 9front@9front.org
Subject: Re: [9front] delkey(1)
Date: Wed, 30 Sep 2015 08:35:05 +0900	[thread overview]
Message-ID: <A57E4659-12E4-4865-9A7E-B50162DAD372@ar.aichi-u.ac.jp> (raw)
In-Reply-To: <alpine.LNX.2.00.1509300019580.2819@localhost>

Hello

> 2015/09/30 7:21、Julius Schmidt <aiju@phicode.de> のメール:
> 
> delkey(1) strikes me as stupid.
> it should be more like
> 
> % delkey
> echo 'delkey proto=hj user=dicks' >/mnt/factotum/ctl
> echo 'delkey proto=p9sk1 user=glenda' > /mnt/factotum/ctl
> etc
> 
> instead of the silly yes/no prompting.

I love the script below.

hebe% cat /usr/local/bin/rc/fact
#!/bin/rc
#
#	fact is a tool to manage factotum. 
#

rfork e

usage='usage: fact [-adl]'
fn addkey {
	echo adding to $1
	cat $1
	echo '# put data and RETURN'
	awk '/^$/{exit} /.+/{print}' | read -m >/$1
#	awk '/^$/{exit} /.+/{print}' >/$1
}

fn delkey {
	echo deleting from $1
	#sed s/key/delkey/g < $1
	sed 's/key/delkey/g;s/!.*?//g' < $1
	echo '# send and RETURN'
	awk '/^$/{exit} /.+/{print}' | read -m > $1
#	awk '/^$/{exit} /.+/{print}' > $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
	}
hebe% 



  reply	other threads:[~2015-09-29 23:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-29 22:21 delkey(1) Julius Schmidt
2015-09-29 23:35 ` arisawa [this message]
2015-10-07  0:47 [9front] delkey(1) sl
2015-10-23 10:16 ` Ethan Grammatikidis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A57E4659-12E4-4865-9A7E-B50162DAD372@ar.aichi-u.ac.jp \
    --to=arisawa@ar.aichi-u.ac.jp \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).