summaryrefslogtreecommitdiff
path: root/create-temp
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2008-06-07 21:13:33 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2008-06-07 21:13:33 +0000
commitf4f6cb4a18eeca6453b9c643d27e57f0d08944cd (patch)
tree41e35c478930c304ebc7957c5ed5b9c2939a82e4 /create-temp
parent5aa20aef91ff4b645d10c6ee599cd75235b43309 (diff)
Add create-temp
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@355 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
Diffstat (limited to 'create-temp')
-rwxr-xr-xcreate-temp19
1 files changed, 19 insertions, 0 deletions
diff --git a/create-temp b/create-temp
new file mode 100755
index 0000000..fe9da4c
--- /dev/null
+++ b/create-temp
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -e
+
+TODAY="$(date '+%F')"
+BASE="$HOME/.temp"
+TARGET="$HOME/tmp"
+
+
+rmdir "$BASE/"* 2> /dev/null || true
+
+[ -d "$BASE/$TODAY" ] || mkdir "$BASE/$TODAY"
+if ! [ -L "$TARGET" ] && [ -e "$TARGET" ]; then
+ echo "$0: '$TARGET' already exists and is not a symlink." >&2
+ exit 1;
+fi
+
+rm -f "$TARGET"
+ln -s "$BASE/$TODAY" "$TARGET"