Commits

Cameron Simpson  committed 02c4ec5

status.report: script for summarising status is easy to read/parse/diff format

  • Participants
  • Parent commits 86e2383

Comments (0)

Files changed (1)

File bin/status.report

+#!/bin/sh
+#
+# Generate a status report of similar form to sysctl output 
+#       - Cameron Simpson <cs@zip.com.au> 26dec2012
+#
+
+set -ue
+
+cmd=`basename "$0"`
+usage="Usage: $cmd [-/ sep] prefix command [args...]"
+
+sep_re='[ \t][ \t]*'
+
+badopts=
+
+while [ $# -gt 0 ]
+do
+  case "$1" in
+    -/) sep_re=$2; shift ;;
+    -/*)sep_re=`expr "x$1" : 'x-/\(.*\)'` ;;
+    --) shift; break ;;
+    -?*)echo "$cmd: unrecognised option: $1" >&2
+        badopts=1
+        ;;
+    *)  break ;;
+  esac
+  shift
+done
+
+if [ $# = 0 ]
+then
+  echo "$cmd: missing prefix" >&2
+  badopts=1
+else
+  prefix=$1
+  shift
+fi
+
+if [ $# = 0 ]
+then
+  echo "$cmd: missing command" >&2
+  badopts=1
+fi
+
+[ $badopts ] && { echo "$usage" >&2; exit 2; }
+
+set -x
+
+"$@" \
+| sed -n "s$sep_re\\(.*\\)=\\1p" \
+| sed "s^$prefix." \
+| sort