diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 17:14:36 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 17:14:36 +0300 |
commit | 2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f (patch) | |
tree | f6343b1ce11a8c87251dd27cf3d3e26b50693fa7 /rc/bin/delkey | |
parent | e463eb40363ff4c68b1d903f4e0cdd0ac1c5977f (diff) |
Import sources from 2011-03-30 iso image - rc
Diffstat (limited to 'rc/bin/delkey')
-rwxr-xr-x | rc/bin/delkey | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/rc/bin/delkey b/rc/bin/delkey new file mode 100755 index 000000000..c80af6a7b --- /dev/null +++ b/rc/bin/delkey @@ -0,0 +1,52 @@ +#!/bin/rc + +rfork e + +ctl = /mnt/factotum/ctl +if(test -r /mnt/term/mnt/factotum/ctl) + ctl = /mnt/term/mnt/factotum/ctl + +fn forceit { + switch($force){ + case no + echo -n $* '? [y/n]' > /dev/cons + ok = `{read} + switch($ok){ + case y* Y* + echo yes + case q* Q* + exit '' + case * + echo no + } + case * + echo yes + } +} + +fn deleteit { + key = `{echo $* | sed 's/ ![0-9a-zA-Z_]+\??/ /g' | sed 's/ +$//'} + if(~ `{forceit del$key} yes) + if(! echo del$key > $ctl) + exit bad +} + +force = no + +if(~ $1 '-f'){ + force = yes + shift +} + +ifs=' +' + +if(~ $#* 0){ + for(i in `{cat $ctl}) + deleteit $i + exit '' +} + +for(i in `{grep $"* $ctl}) + deleteit $i +exit '' |