1
0

delkey 643 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/rc
  2. rfork e
  3. ctl = /mnt/factotum/ctl
  4. if(test -r /mnt/term/mnt/factotum/ctl)
  5. ctl = /mnt/term/mnt/factotum/ctl
  6. fn forceit {
  7. switch($force){
  8. case no
  9. echo -n $* '? [y/n]' > /dev/cons
  10. ok = `{read}
  11. switch($ok){
  12. case y* Y*
  13. echo yes
  14. case q* Q*
  15. exit ''
  16. case *
  17. echo no
  18. }
  19. case *
  20. echo yes
  21. }
  22. }
  23. fn deleteit {
  24. key = `{echo $* | sed 's/ ![0-9a-zA-Z_]+\??/ /g' | sed 's/ +$//'}
  25. if(~ `{forceit del$key} yes)
  26. if(! echo del$key > $ctl)
  27. exit bad
  28. }
  29. force = no
  30. if(~ $1 '-f'){
  31. force = yes
  32. shift
  33. }
  34. ifs='
  35. '
  36. if(~ $#* 0){
  37. for(i in `{cat $ctl})
  38. deleteit $i
  39. exit ''
  40. }
  41. for(i in `{grep $"* $ctl})
  42. deleteit $i
  43. exit ''