summaryrefslogtreecommitdiff
path: root/create-temp
blob: fe9da4c3990a91c601d7806129d4df2d017e63fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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"