Skip to content

Commit

Permalink
Run hooks on rcdn as indicated by the manpage
Browse files Browse the repository at this point in the history
- Make sure IFS in rcup and rcdn isn't left in an incorrect state when
  the output of lsrc is empty.
- Add tests to check that hooks run on rcdn and rcup by default.
  • Loading branch information
bturrubiates authored and mike-burns committed Jan 7, 2015
1 parent 366dd72 commit 40bb6ef
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bin/rcdn.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ handle_command_line() {
local arg_tags=
local verbosity=0
local version=0
local run_hooks=0
local run_hooks=1
local dotfiles_dirs=
local files=
local excludes=
Expand Down Expand Up @@ -124,4 +124,5 @@ for dest_and_src in $dests_and_srcs; do
remove_link "$dest" "$dest" "$sigil"
done

IFS="$saved_ifs"
run_hooks post down
1 change: 1 addition & 0 deletions bin/rcup.in
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,5 @@ for dest_and_src in $dests_and_srcs; do
handle_file "$GENERATE" "$src" "$dest" "$sigil"
done

IFS="$saved_ifs"
run_hooks post up
5 changes: 4 additions & 1 deletion test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ TESTS = \
rcup-hostname.t \
rcup-standalone.t \
rcup-symlink-dirs.t \
rcup-usage.t
rcup-usage.t \
rcdn-hooks.t \
rcup-hooks.t


dist_check_SCRIPTS = $(TESTS)
dist_check_DATA = helper.sh
Expand Down
19 changes: 19 additions & 0 deletions test/rcdn-hooks.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$ . "$TESTDIR/helper.sh"

Pre-down and post-down hooks should run by default

$ mkdir -p .dotfiles/hooks
> touch .dotfiles/hooks/pre-down .dotfiles/hooks/post-down
> chmod +x .dotfiles/hooks/pre-down .dotfiles/hooks/post-down

$ echo 'echo "example" > /tmp/test' > .dotfiles/hooks/pre-down
> echo 'cat /tmp/test; rm /tmp/test' > .dotfiles/hooks/post-down

$ rcdn
example

Ensure that hooks run when output of lsrc is non-empty
$ touch .dotfiles/testrc
> rcup
> rcdn
example
18 changes: 18 additions & 0 deletions test/rcup-hooks.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$ . "$TESTDIR/helper.sh"

Pre-up and post-up hooks should run by default

$ mkdir -p .dotfiles/hooks
> touch .dotfiles/hooks/pre-up .dotfiles/hooks/post-up
> chmod +x .dotfiles/hooks/pre-up .dotfiles/hooks/post-up

$ echo 'echo "example" > /tmp/test' > .dotfiles/hooks/pre-up
> echo 'cat /tmp/test; rm /tmp/test' > .dotfiles/hooks/post-up

$ rcup
example

Ensure that hooks run when output of lsrc is non-empty
$ touch .dotfiles/testrc
> rcup
example

0 comments on commit 40bb6ef

Please sign in to comment.