#!/bin/sh
if [ $# -lt 2 ]
then
  echo "Error - usage is as follows:"
  echo "   $0 <name_to_hash> <command to run> <args for command>..."
  exit 1
else
  USER="$1"
  shift
  sh -c "chhashdir $*"
  ret=$?
  case $ret in
    0) ;;
    1) echo "No hash directory for $USER, or permissions problem." >&2
       ;;
    2) echo "Couldn't hash $USER - length, invalid characters??" >&2
       ;;
  111) echo "Couldn't exec $1" >&2
       ;;
  127) echo "Couldn't find $1" >&2
       ;;
    *) ;;
  esac
  exit $ret
fi
