summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2015-02-03 23:14:24 +0100
committerPeter Palfrader <peter@palfrader.org>2015-02-03 23:14:24 +0100
commitb43a17f87d62ab2b03661c048bbe297acc980e6a (patch)
tree213b122322106887bc2c340e69e8c6d0b60eefe9
parentd4d53d3c2e9fabf6512551f133dcf74a52d79a0b (diff)
Make create-temp smarter about the yesterday link
-rwxr-xr-xcreate-temp12
1 files changed, 8 insertions, 4 deletions
diff --git a/create-temp b/create-temp
index a12b7fe..46fdac8 100755
--- a/create-temp
+++ b/create-temp
@@ -23,7 +23,6 @@
set -e
-YESTERDAY="$(date -d '1 day ago' '+%F')"
TODAY="$(date '+%F')"
BASE="$HOME/.temp"
TARGET="$HOME/tmp"
@@ -43,10 +42,15 @@ target_dir="$(dirname "$TARGET")"
if [ "${BASE##$target_dir/}" != "$BASE" ]; then
BASE="${BASE##$target_dir/}"
fi
+OLD="$(readlink -f "$TARGET")"
+
rm -f "$TARGET"
ln -s "$BASE/$TODAY" "$TARGET"
-if [ -e "$BASE/$YESTERDAY" ]; then
- rm -f "$BASE/yesterday"
- ln -s "$YESTERDAY" "$BASE/yesterday"
+if [ -e "$OLD" ]; then
+ bn="$(basename "$OLD")"
+ if [ "$BASE/$bn" = "$OLD" ]; then
+ OLD="$bn"
+ fi
+ ln -s -T -f "$OLD" "$BASE/yesterday"
fi