]> gitweb.fluxo.info Git - git-hooks.git/commitdiff
Verify that all required arguments are passed in and return with an
authorBenjamin C Meyer <ben@meyerhome.net>
Sat, 20 Mar 2010 20:59:40 +0000 (16:59 -0400)
committerBenjamin C Meyer <ben@meyerhome.net>
Sat, 20 Mar 2010 20:59:40 +0000 (16:59 -0400)
error if they are not.

Signed-off-by: Benjamin C Meyer <ben@meyerhome.net>
git-hooks

index 9e4e7e2114fa833a5258bfb326740f9f470b8150..89b048907d7da5cec38b2e0ea6614edd4879ed20 100755 (executable)
--- a/git-hooks
+++ b/git-hooks
@@ -47,6 +47,10 @@ function list_hooks_in_dir
 function run_hooks
 {
     dir="${1}"
+    if [[ -z ${dir} || ! -d "${dir}" ]] ; then
+        echo "run_hooks requires a directory name as an argument."
+        return 1
+    fi
     shift 1
     for hook in `list_hooks_in_dir "${dir}"`
     do
@@ -63,6 +67,10 @@ function run_hook
 {
     set -e
     hook=`basename "${1}"`
+    if [ -z ${hook} ] ; then
+        echo "run requires a hook argument"
+        return 1
+    fi
     shift 1
     for dir in `hook_dirs "${hook}"`; do
         if [ ! -d "${dir}" ] ; then