From fc648042ca2e753b8ecdabc5fa52aea5313c3b03 Mon Sep 17 00:00:00 2001 From: Mike Burns Date: Mon, 5 Aug 2013 06:15:17 +0200 Subject: Add -C for copying files Some files prefer to be copies instead of symlinks---for example, OpenSSH ignores symlinks. Add the `-C` option to mkrc(1) and rcup(1) to handle this. mkrc -C .ssh rcup -C ssh This does raise a synchronization problem that I do not yet know how to solve; namely, what to do when the rc file changes. Perhaps a `rcsync` command is in order; perhaps `rcup` should handle this; perhaps `rcsync` is a better name for `rcup`. --- bin/rcup | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'bin/rcup') diff --git a/bin/rcup b/bin/rcup index 37ccb2f..df9adac 100755 --- a/bin/rcup +++ b/bin/rcup @@ -7,12 +7,11 @@ link_file() { local src=$1 local dest=$2 - $PRINT "linking $dest" if [ -h $dest ]; then - rm -f $dest + $RM -f $dest fi - $LN -s $src $dest + $LN $src $dest } replace_file() { @@ -78,24 +77,29 @@ handle_command_line() { local files= local excludes= local includes= + local always_copy=0 REPLACE_ALL=0 - - while getopts VqvfiI:e:t:d: opt; do + while getopts CVqvfiI:e:t:d: opt; do case "$opt" in - e) excludes="$excludes $OPTARG";; + C) always_copy=1 ;; + d) dotfiles_dirs="$dotfiles_dirs $OPTARG" ;; + e) excludes="$excludes $OPTARG" ;; f) REPLACE_ALL=1 ;; i) REPLACE_ALL=0 ;; - I) includes="$includes $OPTARG";; + I) includes="$includes $OPTARG" ;; + q) verbosity=$(($verbosity - 1)) ;; t) arg_tags="$arg_tags $OPTARG" ;; v) verbosity=$(($verbosity + 1)) ;; - q) verbosity=$(($verbosity - 1)) ;; - d) dotfiles_dirs="$dotfiles_dirs $OPTARG" ;; V) version=1 esac done shift $(($OPTIND-1)) + if [ $always_copy -eq 1 ]; then + LN=cp + fi + handle_common_flags rcup $version $verbosity tags=${arg_tags:-$TAGS} -- cgit v1.2.3