aboutsummaryrefslogtreecommitdiff
path: root/davcpy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'davcpy.sh')
-rwxr-xr-xdavcpy.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/davcpy.sh b/davcpy.sh
new file mode 100755
index 00000000..99a47b6d
--- /dev/null
+++ b/davcpy.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+usage () { echo "$0 <src> <cadaver-args>*" >/dev/stderr; }
+error () { echo "$1" >/dev/stderr; usage; exit 1; }
+
+test $# '<' 3 || \
+ error "Source and cadaver arguments expected!";
+
+src="$1"; shift;
+test -r "$src" || \
+ error "Source argument should be a readable file or directory!";
+
+cd "$(dirname "$src")";
+src="$(basename "$src")";
+root="$(pwd)";
+rc="$(mktemp)";
+{
+ find "$src" '(' -type d -a -readable ')' \
+ -printf 'mkcol "%p"\n';
+ find "$src" '(' -type f -a -readable ')' \
+ -printf 'cd "%h"\nlcd "%h"\n' \
+ -printf 'mput "%f"\n' \
+ -printf 'cd -\nlcd "'"$root"'"\n';
+ echo "quit";
+} > "$rc";
+
+cadaver -r "$rc" "$@";
+rm -f "$rc";