From 3adcb218cbb42026bc0ef906b219f0e1888220cd Mon Sep 17 00:00:00 2001 From: Mike Burns Date: Fri, 12 Jul 2013 23:38:19 +0200 Subject: Hide duplicates With multiple source directories it is possible to have duplicates. Consider these source directories, `a` and `b`: |-- a | |-- bar | `-- foo `-- b |-- baz `-- foo The goal is to have this: .bar -> a/bar .baz -> b/baz .foo -> a/foo Note the duplcate `foo` file. We now handle this, in `lsrc` and therefore in `rcup`. We do this by storing a `:`-separated string of destination files (e.g. `.foo`) and `grep`ing that string before we operate on any destination. --- bin/lsrc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/lsrc b/bin/lsrc index e2a3618..cdebfeb 100755 --- a/bin/lsrc +++ b/bin/lsrc @@ -58,7 +58,11 @@ link_file() { local dotted=$4 local dest_file=`build_path $dest_dir $file $dotted` - $PRINT $dest_file:$dotfiles_dir/$file + if echo $DEST_STACK | grep -vq ":$dest_file"; then + DEST_STACK="$DEST_STACK:$dest_file" + + $PRINT $dest_file:$dotfiles_dir/$file + fi } handle_file() { @@ -131,6 +135,8 @@ handle_command_line() { FILES=$@ } +DEST_STACK= + if [ -e $HOME/.rcrc ]; then . $HOME/.rcrc fi -- cgit v1.2.3