]> arthur.barton.de Git - ax-zsh.git/blobdiff - core/30_env/30_env.zshrc
30_env.ax-io: Try to use a user-specific subfolder when TMPDIR is not set
[ax-zsh.git] / core / 30_env / 30_env.zshrc
index b8ee8338f6a501a5dc5e11de2b1182f7b99fe69d..4187712e17cae0ced9455627de536ee8d2ccdac6 100644 (file)
@@ -1,13 +1,17 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
-# 30_env.zshrc: Setup environment
+# 30_env.ax-io: 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 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
 
-# Make sure TMP and TMPDIR become exported when they are set:
-[[ -n "$TMP" ]] && export TMP
-[[ -n "$TMPDIR" ]] && export TMPDIR
+# TMPDIR is the only one required to be set, but make sure that TMP, TEMP
+# and TEMPDIR are set to the same sane path name when already present in the
+# environment:
+[[ -n "$TMP" ]] && TMP="$TMPDIR"
+[[ -n "$TEMP" ]] && TEMP="$TMPDIR"
+[[ -n "$TEMPDIR" ]] && TEMPDIR="$TMPDIR"