diff options
author | Mike Burns <mike@mike-burns.com> | 2013-07-12 23:38:19 +0200 |
---|---|---|
committer | Mike Burns <mike@mike-burns.com> | 2013-07-12 23:44:16 +0200 |
commit | 3adcb218cbb42026bc0ef906b219f0e1888220cd (patch) | |
tree | 33a459b9749bc4cfa44712345c1e1be560b7cce9 | |
parent | c5ae3e947a891975a2f8edee5a8349a2f46e45b9 (diff) |
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.
-rwxr-xr-x | bin/lsrc | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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 |