#!/usr/bin/env bash
-if [ -z "$1" ] || [ "$1" = "-h" ] ; then
- echo "usage: ./process-pid.sh [command] [pid]"
- exit 1;
+USAGE="usage: ./process-pid.sh {[-h, -a], [-f, -e] <pid>}, -s <regexp>"
+
+if [ -z "$1" ]; then
+ echo "$USAGE"; exit 1
+
+elif [[ "$1" =~ ^-?[0-9]+$ ]]; then # unportable :(
+ if `ps $1 > /dev/null 2>&1`; then
+ echo "you win!"; exit 0
+
+ else
+ echo -ne "invalid pid\n$USAGE"; exit 1
+ fi
+
+elif [[ "$1" -eq "-h" ]]; then
+ echo "$USAGE"; exit 0
fi