summaryrefslogtreecommitdiff
path: root/jh.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-09-27 14:42:10 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-09-27 14:42:10 -0400
commitc3d8da0e89d3f2213933ff85dc0cca7d829442ed (patch)
tree967259a8338aa703195b94a9d5131c00545b0f3a /jh.sh
Initial commit
Diffstat (limited to 'jh.sh')
-rw-r--r--jh.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/jh.sh b/jh.sh
new file mode 100644
index 0000000..a7c25a9
--- /dev/null
+++ b/jh.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+if [[ -z "$jh_cmd" ]]; then
+ export jh_cmd=$0
+fi
+export jh_short=${jh_cmd##*/}
+
+if [[ -z "$JH_PATH" ]]; then
+ export JH_PATH=/usr/share/jh
+fi
+
+usage() {
+ cmd="${1-$0}"
+ file="$JH_PATH/jh-$cmd.help.txt"
+ if [[ -f "$JH_PATH/jh-$cmd.help.txt" ]]; then
+ sed "s|@cmd@|$jh_short|g" "$file" >> /dev/stderr
+ else
+ echo "$jh_short: Cannot find help file for '$cmd'" >> /dev/stderr
+ fi
+}
+
+run() {
+ if [[ $# < 1 ]]; then
+ usage ''
+ exit 1;
+ fi
+ cmd=$1
+ shift
+
+ file="$JH_PATH/jh-$cmd"
+ if [[ -x "$file" ]]; then
+ "$file" "$@"
+ exit $?
+ else
+ echo "$jh_short: Cannot find command '$cmd'" >> /dev/stderr
+ fi
+}
+
+[[ "$jh_cmd" == "$0" ]] && run "$@"