Plan 9 from Bell Labs’s /usr/web/sources/plan9/rc/bin/delkey

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


#!/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 ''

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.