blob: 4b0dff2c433bced72bec5b4a015b51a9a49c1b33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/bin/zsh
set -o shwordsplit
log() {
if [[ $dry == "1" ]]; then
echo "[DRY_RUN]: $1"
else
echo "$1"
fi
}
execute() {
log "execute $@"
if [[ $dry == "1" ]]; then
return
fi
"$@"
}
copy_dir() {
from=$1
to=$2
pushd $from
dirs="$(find . -maxdepth 1 -mindepth 1 -type d)"
for dir in $dirs; do
execute rm -rf $to/$dir
execute cp -r $dir $to/$dir
done
popd
}
copy_file() {
from=$1
to=$2
name=$(basename $from)
execute rm $to/$name
execute cp $from $to/$name
}
|