From 971a2f9e5b2bcbfd0e1589dbd0dd602f7e2cd1c9 Mon Sep 17 00:00:00 2001 From: Mike Burns Date: Fri, 16 Aug 2013 17:41:10 +0200 Subject: Add -kK for rcup and rcdn The hooks can be skipped using `-K`, if needed and they can be forced with the `-k` flag. --- NEWS.md.in | 1 + bin/rcdn | 4 ++++ bin/rcup | 6 +++++- man/rcdn.1 | 6 +++++- man/rcup.1 | 12 +++++++++--- share/rcm.sh.in | 16 +++++++++------- 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/NEWS.md.in b/NEWS.md.in index 0e7c8df..de7ce36 100644 --- a/NEWS.md.in +++ b/NEWS.md.in @@ -7,6 +7,7 @@ rcm (@PACKAGE_VERSION@) unstable; urgency=low * Always copy the files listed in COPY_ALWAYS. * Show whether the file is a copy or symlink using lsrc -F. * Add hooks for pre-up, post-up, pre-down, and post-down. + * rcup -K and rcdn -K to ignore these hooks. -- Mike Burns Mon, 05 Aug 2013 16:43:33 +0200 diff --git a/bin/rcdn b/bin/rcdn index cae9dc8..2c52be4 100755 --- a/bin/rcdn +++ b/bin/rcdn @@ -22,6 +22,7 @@ handle_command_line() { local arg_tags= local verbosity=0 local version=0 + local run_hooks=0 local dotfiles_dirs= local files= local excludes= @@ -30,6 +31,8 @@ handle_command_line() { while getopts VqvI:x:t:d: opt; do case "$opt" in I) includes="$includes $OPTARG";; + k) run_hooks=1 ;; + K) run_hooks=0 ;; t) arg_tags="$arg_tags $OPTARG" ;; v) verbosity=$(($verbosity + 1));; q) verbosity=$(($verbosity - 1));; @@ -45,6 +48,7 @@ handle_command_line() { tags=${arg_tags:-$TAGS} dotfiles_dirs=${dotfiles_dirs:-$DOTFILES_DIRS} files=$@ + RUN_HOOKS=$run_hooks for tag in $tags; do LS_ARGS="$LS_ARGS -t $tag" diff --git a/bin/rcup b/bin/rcup index 5a42a81..2dff893 100755 --- a/bin/rcup +++ b/bin/rcup @@ -89,6 +89,7 @@ handle_command_line() { local arg_tags= local verbosity=0 local version=0 + local run_hooks=0 local dotfiles_dirs= local files= local excludes= @@ -96,13 +97,15 @@ handle_command_line() { local always_copy=0 REPLACE_ALL=0 - while getopts CVqvfiI:x:t:d: opt; do + while getopts CVqvfikKI:x:t:d: opt; do case "$opt" in C) always_copy=1 ;; d) dotfiles_dirs="$dotfiles_dirs $OPTARG" ;; f) REPLACE_ALL=1 ;; i) REPLACE_ALL=0 ;; I) includes="$includes $OPTARG" ;; + k) run_hooks=1 ;; + K) run_hooks=0 ;; q) verbosity=$(($verbosity - 1)) ;; t) arg_tags="$arg_tags $OPTARG" ;; v) verbosity=$(($verbosity + 1)) ;; @@ -120,6 +123,7 @@ handle_command_line() { tags=${arg_tags:-$TAGS} DOTFILES_DIRS=${dotfiles_dirs:-$DOTFILES_DIRS} + RUN_HOOKS=$run_hooks files=$@ for tag in $tags; do diff --git a/man/rcdn.1 b/man/rcdn.1 index 24ca1a2..d6737cf 100644 --- a/man/rcdn.1 +++ b/man/rcdn.1 @@ -6,7 +6,7 @@ .Nd remove dotfiles .Sh SYNOPSIS .Nm rcdn -.Op Fl vq +.Op Fl kKvq .Op Fl d Ar dir .Op Fl I Ar excl_pat .Op Fl t Ar tag @@ -58,6 +58,10 @@ This can be repeated with additional patterns. See .Xr lsrc 1 , .Sx EXCLUDE PATTERN , for more details. +.It Fl k +run pre- and post-hooks. This is the default. +.It Fl K +skip pre- and post-hooks .It Fl q decrease verbosity .It Fl t Ar TAG diff --git a/man/rcup.1 b/man/rcup.1 index 4140205..9b2aa08 100644 --- a/man/rcup.1 +++ b/man/rcup.1 @@ -6,7 +6,7 @@ .Nd update and install dotfiles .Sh SYNOPSIS .Nm rcup -.Op Fl Cfiqv +.Op Fl CfikKqv .Op Fl d Ar dir .Op Fl I Ar excl_pat .Op Fl t Ar tag @@ -32,11 +32,11 @@ install dotfiles from the .Ar DIR . This can be specified multiple times. .It Fl f -If the rc file already exists in your home directory but does not match +if the rc file already exists in your home directory but does not match the file in your dotfiles directory, remove the rc file then create the symlink .It Fl i -If the rc file already exists in your home directory but does not match +if the rc file already exists in your home directory but does not match the file in your dotfiles directory, prompt for how to handle it. This is the default .It Fl I Ar EXCL_PAT @@ -50,6 +50,12 @@ This can be repeated with additional patterns. See .Xr lsrc 1 , .Sx EXCLUDE PATTERN , for more details. +.It Fl k +run pre- and post-hooks (see +.Sx DIRECTORY LAYOUT +for more details on hooks). This is the default. +.It Fl K +skip pre- and post-hooks .It Fl t Ar TAG install dotfiles according to .Ar TAG diff --git a/share/rcm.sh.in b/share/rcm.sh.in index 36b6762..e01ec59 100644 --- a/share/rcm.sh.in +++ b/share/rcm.sh.in @@ -106,11 +106,13 @@ run_hooks() { local when=$1 local direction=$2 - 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 - done + 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 + done + fi } -- cgit v1.2.3