chiark / gitweb /
debian/changelog: Another pre-release.
[distorted-keys] / cryptop.list
index c51f40221e958d54bb48c0a7a0fc472c2110a03b..96f9a653c5397e9c9ab73c9d635219cefb5bbd67 100755 (executable)
@@ -38,11 +38,16 @@ Options:
   -a           Show keys owned by all users.
   -u USER      Show keys owned by USER.
 
-A COLUMN spec consists of a column name and an optional column width,
-separated by a colon.  The widths of omitted columns are computed
-automatically.
-
-Columns:
+A COLUMN spec consists of a column name and an optional column width; the
+separator character determines the behaviour as shown below.  The default is
+\`+0'.
+  NAME=WIDTH   Exact width: truncate the contents to fit if necessary.
+  NAME:WIDTH   Minimum width: spill into the next column (breaking the
+                 alignment) if necessary.
+  NAME+WIDTH   Minimum width: if a value won't fit then make the entire
+                 column wider.
+
+Columns names:
   flags                Various flags for the key.  (Unset flags are shown as \`.')
                  R     key has recovery information
                  !     key nub needs recovery
@@ -80,7 +85,7 @@ col_label () {
   label=$1
 
   case $all,$label in
-    nil,$USERV_USER*) plabel=${label#*/} ;;
+    nil,$USERV_USER/*) plabel=${label#*/} ;;
     t,*) plabel=${label%%/*}:${label#*/} ;;
   esac
   echo "$plabel"
@@ -126,14 +131,24 @@ while getopts "HaC:u:" opt; do
 done
 shift $(( $OPTIND - 1 ))
 case $# in 0) set "*" ;; esac
+
+## Find where to look for keys, and check that there might be some.
+case $all in
+  t) dir=store ;;
+  nil) dir=store/$user ;;
+esac
+if [ ! -d $KEYS/$dir ]; then echo >&2 "$quis: no keys"; exit 1; fi
+
+## Find the metadata files.  This tells us where the keys are.
 cd $KEYS
+metas=$(find $dir -type f -name meta | sort)
+case "x$metas" in x) echo >&2 "$quis: no keys"; exit 1 ;; esac
 
 ## First pass: validate the column specifications.  Translate all bare column
 ## names into explicit `NAME+0' forms.  Decide whether we need a width-
 ## measuring pass.
 calcwd=nil
-cc=$cols
-wdcols=""
+cc=$cols cols=""
 while :; do
 
   ## Pick off the next column name.  If none are left, leave the loop.
@@ -154,11 +169,11 @@ while :; do
   case "$col" in
     *[:=+]*)
       wd=${col#*[:=+]}
-      wdcols=${wdcols:+$wdcols,}$col
+      cols=${cols:+$cols,}$col
       checknumber "column width" "$wd"
       ;;
     *)
-      wdcols=${wdcols:+$wdcols,}$col+0
+      cols=${cols:+$cols,}$col+0
       ;;
   esac
 
@@ -177,13 +192,6 @@ while :; do
   ## passes, because it may contribute to width.)
   doheader=$header
 
-  ## Find the metadata files.  This tells us where the keys are.
-  case $all in
-    t) dir=store ;;
-    nil) dir=store/$user ;;
-  esac
-  metas=$(find store -type f -name meta)
-
   ## Work through the keys we found.
   while :; do
 
@@ -204,8 +212,8 @@ while :; do
     ## Now iterate over the columns.  If we're calculating widths, use the
     ## ones we worked out last time, and clear the list so we can build a new
     ## one as we go.
-    case $calcwd in t) cols=$wdcols ;; esac
-    cc=$cols wdcols="" sep=""
+    cc=$cols sep=""
+    case $calcwd in t) cols="" ;; esac
     while :; do
 
       ## Pick off the next column spec.
@@ -229,12 +237,12 @@ while :; do
       ## idea of the column width.  If we're printing, work out a format.
       case $calcwd,$col in
        t,*[:=]*)
-         wdcols=${wdcols:+$wdcols,}$col
+         cols=${cols:+$cols,}$col
          ;;
        t,*+*)
          colwd=$(( $(echo "$value" | wc -c) - 1 ))
          if [ $colwd -gt $wd ]; then wd=$colwd; fi
-         wdcols=${wdcols:+$wdcols,}$name+$wd
+         cols=${cols:+$cols,}$name+$wd
          ;;
        nil,*[=+]*)
          fmt="%-${wd}.${wd}s"