From 83c4875e23bb7595689ddd228a9825264b15f318 Mon Sep 17 00:00:00 2001 From: Pablo Olmos de Aguilera Corradini Date: Sun, 15 Sep 2013 16:50:02 -0300 Subject: Allow {pre,post}-up hook directories If the `pre-up` or `post-up` files are actually directories, run the executable contents of them in an arbitrary order. --- man/rcup.1 | 11 ++++++++--- share/rcm.sh.in | 8 +++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/man/rcup.1 b/man/rcup.1 index 8839159..3304436 100644 --- a/man/rcup.1 +++ b/man/rcup.1 @@ -114,9 +114,14 @@ Hooks go in a directory named .Pa hooks . Two hooks are supported by .Nm rcup : -pre-up and post-up . These go in files with predictable filenames: -.Pa .dotfiles/hooks/pre-up and -.Pa .dotfiles/hooks/post-up . +pre-up and post-up. These go in files or directories with predictable filenames: +.Pa .dotfiles/hooks/pre-up +and +.Pa .dotfiles/hooks/post-up , +or +.Pa .dotfiles/hooks/pre-up/* +and +.Pa .dotfiles/hooks/post-up/* . These files must be executable. They are run every time .Nm is run, and therefore must be idempotent. diff --git a/share/rcm.sh.in b/share/rcm.sh.in index 7c0b6e2..c9a98b3 100644 --- a/share/rcm.sh.in +++ b/share/rcm.sh.in @@ -107,14 +107,12 @@ run_hooks() { $DEBUG " with DOTFILES_DIRS: $DOTFILES_DIRS" local when=$1 local direction=$2 + local hook_file="$dotfiles_dir/hooks/$when-$direction" if [ $RUN_HOOKS -eq 1 ]; then for dotfiles_dir in $DOTFILES_DIRS; do - $DEBUG "hook: $dotfiles_dir/hooks/$when-$direction" - if [ -x "$dotfiles_dir/hooks/$when-$direction" ]; then - $VERBOSE "running $when-$direction hooks for $dotfiles_dir" - $dotfiles_dir/hooks/$when-$direction - fi + $VERBOSE "running $when-$direction hooks for $dotfiles_dir" + find "$dotfiles_dir/hooks/$when-$direction" -type f -perm +111 -print -exec {} \; done fi } -- cgit v1.2.3