diff options
author | patrick brisbin <pbrisbin@gmail.com> | 2014-02-28 09:46:36 -0500 |
---|---|---|
committer | patrick brisbin <pbrisbin@gmail.com> | 2014-02-28 09:46:36 -0500 |
commit | 0d767c39e99685e690a41085b18b2a2690f39e20 (patch) | |
tree | f633e360972a913fb28d8faf48bf75c4f8ecaa44 | |
parent | fcd3f2d3a793895e2695ad6bf52fde9578f6b148 (diff) |
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.
-rw-r--r-- | share/rcm.sh.in | 21 |
1 files changed, 11 insertions, 10 deletions
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 } |