summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rwxr-xr-xutil41
1 files changed, 41 insertions, 0 deletions
diff --git a/util b/util
new file mode 100755
index 0000000..4b0dff2
--- /dev/null
+++ b/util
@@ -0,0 +1,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
+}
+