From 0d767c39e99685e690a41085b18b2a2690f39e20 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Fri, 28 Feb 2014 09:46:36 -0500 Subject: Correctly set hook_file in run_hooks The code was setting the $hook_file variable to $dotfiles_dir/hooks/$when-$direction outside of the loop which actually sets the $dotfiles_dir variable to each of the dotfiles directories being processed in turn. This would lead to (for example) /hooks/post-up which is not correct. The fix is to move that logic into the loop. --- share/rcm.sh.in | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'share/rcm.sh.in') diff --git a/share/rcm.sh.in b/share/rcm.sh.in index f6deccd..a5a7679 100644 --- a/share/rcm.sh.in +++ b/share/rcm.sh.in @@ -105,19 +105,20 @@ handle_metadata_flags() { run_hooks() { $DEBUG "run_hooks $1 $2" $DEBUG " with DOTFILES_DIRS: $DOTFILES_DIRS" - local when=$1 - local direction=$2 - local hook_file="$dotfiles_dir/hooks/$when-$direction" - - if [ ! -e "$hook_file" ]; then - $DEBUG "no $when-$direction hook file, skipping" - return 1 - fi + local when="$1" + local direction="$2" + local hook_file if [ $RUN_HOOKS -eq 1 ]; then for dotfiles_dir in $DOTFILES_DIRS; do - $VERBOSE "running $when-$direction hooks for $dotfiles_dir" - find "$hook_file" -type f -perm +111 -print -exec {} \; + hook_file="$dotfiles_dir/hooks/$when-$direction" + + if [ -e "$hook_file" ]; then + $VERBOSE "running $when-$direction hooks for $dotfiles_dir" + find "$hook_file" -type f -perm +111 -print -exec {} \; + else + $DEBUG "no $when-$direction hook present for $dotfiles_dir, skipping" + fi done fi } -- cgit v1.2.3