mirror of
https://github.com/urbit/shrub.git
synced 2024-08-17 08:00:39 +03:00
pkg/symbolic-merge.sh from @Fang-
This commit is contained in:
parent
5f4c02c6d2
commit
f277c9f1ae
26
pkg/symbolic-merge.sh
Executable file
26
pkg/symbolic-merge.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# call from within pkg/ as ./symbolic-merge.sh source-pkg target-pkg
|
||||
|
||||
function link() { # source desk, target desk, filepath
|
||||
local src=${3:2}; # strip leading ./
|
||||
local pax=$src;
|
||||
local rel=$1;
|
||||
while [[ "." != $(dirname "$pax") ]]; do
|
||||
pax=$(dirname "$pax");
|
||||
rel="../$rel";
|
||||
done;
|
||||
ln -sf "../$rel/$src" "../$2/$src";
|
||||
}
|
||||
|
||||
# mirror directory structure
|
||||
cd $1;
|
||||
find . -type d -exec mkdir -p ../$2/{} \;
|
||||
|
||||
# symlink all files, overwriting existing ones
|
||||
export -f link
|
||||
find . -type f \
|
||||
-not -name '*.bill' \
|
||||
-not -name '*.kelvin' \
|
||||
-exec bash -c "link $1 $2 {}" \;
|
||||
|
Loading…
Reference in New Issue
Block a user