keys.delete-keeper: Recovery-key labels are plain words.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 16 Jul 2017 01:04:52 +0000 (02:04 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 16 Jul 2017 01:12:33 +0000 (02:12 +0100)
This is checked when they're created (see `keys.new-recov').  Therefore,
it's not necessary to search recursively under `recov/' hoping to find
`current' links -- which is not especially reliable and somewhat
inefficient -- to enumerate all of the recovery keys.  Standard shell
globbing and checking for `current' links at the next level down is
sufficient and doesn't require messy parsing of find(1) output.

keys.delete-keeper

index edcb718..84a3ae9 100755 (executable)
@@ -54,9 +54,9 @@ if [ -d $KEYS/recov ]; then
   cd $KEYS/recov
 
   ## Work through the available recovery keys.
-  for r in $(find . -type l -name current -print); do
-    r=${r#./}; r=${r%/current}
-    if ! expr >/dev/null "Q$r" : "Q$R_LABEL"; then continue; fi
+  for r in *; do
+    if ! expr >/dev/null "Q$r" : "Q$R_WORD"; then continue; fi
+    if [ ! -l $r/current ]; then continue; fi
 
     ## Add the key to our list.
     recov="$recov$r "
@@ -64,7 +64,7 @@ if [ -d $KEYS/recov ]; then
     ## Now work through the instances.
     ii=""
     for ri in $r/*; do
-      i=${ri##*/}
+      i=${ri#*/}
       case "$i" in *[!0-9]*) continue ;; esac
 
       ## Add the instance to our list.