diff options
author | Mike Burns <mike@mike-burns.com> | 2013-08-11 17:29:01 +0200 |
---|---|---|
committer | Mike Burns <mike@mike-burns.com> | 2013-08-11 21:18:53 +0200 |
commit | 8d7f6c94a3458328b339b6582592b6c1fecec950 (patch) | |
tree | ff9ea4a2a83fafb910d0c604435d648bf01cedbf /bin/rcdn | |
parent | 0fbc27dbe296e03b4001586a7e29780328cbc657 (diff) |
Add the COPY_ALWAYS option
The suite now honors the `COPY_ALWAYS` option in rcrc(5). This can be
set to a space-separated list of file globs. Any file matching a glob is
copied instead of symlinked. This is handy both for secure programs
(`netrc`, `ssh/id_*`) and for programs that oddly re-write files
(`weechat/*`).
To always copy everything, use the `*` glob.
This is reflected throughout the suite as follows:
* lsrc now has a `-F` option which shows a symbol to indicate whether it
is a symlink (`@`) or a copy (`X`).
* rcdn only removes symlinks unless the file under question matches a
`COPY_ALWAYS` glob, in which case it is removed regardless of whether
it is a symlink.
* rcup will copy instead of symlinking any file that matches any
`COPY_ALWAYS` glob.
Diffstat (limited to 'bin/rcdn')
-rwxr-xr-x | bin/rcdn | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -6,10 +6,11 @@ remove_link() { local dest=$1 local original=$2 + local sigil=$3 if [ x$dest = "x/" ]; then $VERBOSE "not a symlink, skipping: $original" - elif [ -L $dest ]; then + elif [ -L $dest -o "x$sigil" = "xX" ]; then $RM -rf $dest rmdir -p `dirname $original` 2>/dev/null else @@ -62,6 +63,8 @@ handle_command_line() { $DEBUG "LS_ARGS: $LS_ARGS" } +LS_ARGS=-F + if [ -e $HOME/.rcrc ]; then . $HOME/.rcrc fi @@ -69,8 +72,12 @@ fi handle_command_line $* for dest_and_src in `lsrc $LS_ARGS`; do - dest=`echo $dest_and_src | sed 's/:.*//'` - src=`echo $dest_and_src | sed 's/.*://'` + saved_ifs=$IFS + IFS=: + set $dest_and_src + IFS=$saved_ifs + dest=$1 + sigil=$3 - remove_link $dest $dest + remove_link $dest $dest $sigil done |