diff options
Diffstat (limited to 'create-temp')
-rwxr-xr-x | create-temp | 12 |
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 |