* `PS1`
* `SHORT_HOST`
* `TERM`
-* `XDG_RUNTIME_DIR`
+* `TMPDIR` (set and always ends with a "/")
* `XDG_CACHE_HOME`
+* `XDG_RUNTIME_DIR`
* `ZSH_CACHE_DIR`
TZ=$(<"/etc/timezone") export TZ
fi
+# Validate temporary directory
+if [[ -z "$TMPDIR" ]]; then
+ echo "WARNING: \"TMPDIR\" is not set, using /tmp as default!" >&2
+ TMPDIR='/tmp/'
+fi
+if [[ ! -w "$TMPDIR" ]]; then
+ echo "WARNING: Temporary directory \"$TMPDIR\" is not writable!" >&2
+fi
+# Make sure TMPDIR ends in a slash (like on macOS by default): this makes its
+# usage a bit safer ...
+case "$TMPDIR" in
+ */) ;;
+ *) TMPDIR="$TMPDIR/"
+esac
+export TMPDIR
+
# Setup XDG cache directory
if [[ -z "$XDG_CACHE_HOME" ]]; then
XDG_CACHE_HOME="$LOCAL_HOME/.cache"
+++ /dev/null
-# AX-ZSH: Alex' Modular ZSH Configuration
-# 30_env.zshrc: Setup environment
-
-# Setup TMPDIR. Try to reset TMPDIR (when it is not set but TMP is), which is
-# common in tools like screen(1) because Linux removes some varibes for
-# "setgit" tools (see <https://bugzilla.redhat.com/show_bug.cgi?id=129682#c1>).
-# And therefore this has to be checked here, because inside of screen probably
-# no login shell is started ...
-[[ -z "$TMPDIR" && -n "$TMP" ]] && TMPDIR="$TMP"
-
-# Make sure TMP and TMPDIR become exported when they are set:
-[[ -n "$TMP" ]] && export TMP
-[[ -n "$TMPDIR" ]] && export TMPDIR
# don't show them now but return.
[[ -z `find "$XDG_CACHE_HOME/axzsh_last_calendar" -mmin -60 2>/dev/null` ]] || return 0
-tmpfile=$(mktemp ${TMPDIR:-/tmp}/calendar.XXXXXX) || return 1
+tmpfile=$(mktemp "$TMPDIR/calendar.XXXXXX") || return 1
calendar -A0 >"$tmpfile"
if [[ -s "$tmpfile" ]]; then
# don't show them now but return.
[[ -z `find "$XDG_CACHE_HOME/axzsh_last_reminder" -mmin -60 2>/dev/null` ]] || return 0
-tmpfile=$(mktemp ${TMPDIR:-/tmp}/icalbuddy.XXXXXX) || return 1
+tmpfile=$(mktemp "$TMPDIR/icalbuddy.XXXXXX") || return 1
if [[ "$LANG" =~ "\.UTF" ]]; then
bul="•"; bul_imp="!"; sep="»"