aboutsummaryrefslogtreecommitdiff
path: root/zsh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-12-30 22:31:30 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-12-30 22:42:56 +1300
commit0d79eeb3ab41cf49310ec53e6cf55ccbfe2f7e31 (patch)
tree7d49a185ae556ee2a89818cab4d6d85747696875 /zsh
parentAdd environment variable (diff)
downloaddotfiles-0d79eeb3ab41cf49310ec53e6cf55ccbfe2f7e31.tar.gz
dotfiles-0d79eeb3ab41cf49310ec53e6cf55ccbfe2f7e31.zip
Fix a zsh-as-sh/ksh-specific issue
Very niche, but interesting to fix anyway
Diffstat (limited to 'zsh')
-rw-r--r--zsh/profile.d/zsh.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/zsh/profile.d/zsh.sh b/zsh/profile.d/zsh.sh
new file mode 100644
index 00000000..47de6d4d
--- /dev/null
+++ b/zsh/profile.d/zsh.sh
@@ -0,0 +1,28 @@
+# Zsh before version 5.3.0 emulating POSIX sh(1) or Korn shell only sources the
+# interactive shell startup file described in ENV if it's set after
+# /etc/profile is sourced, but before ~/.profile is. The other shells I have
+# tried (including modern shells emulating POSIX sh(1)) wait until after
+# ~/.profile is read. This seems to have been fixed in Zsh commit ID fde365e,
+# which was followed by release 5.3.0.
+
+# Is this zsh masquerading as sh/ksh?
+[ -n "$ZSH_VERSION" ] || return
+case $ZSH_NAME in
+ sh|ksh) ;;
+ *) return ;;
+esac
+
+# Iterate through the zsh version number to see if it's at least 5.3.0; if not,
+# we'll have ~/.profile force sourcing $ENV
+if ! (
+ zvs=$ZSH_VERSION
+ for fv in 5 3 0 ; do
+ zv=${zvs%%[!0-9]*}
+ [ "$((zv > fv))" -eq 1 ] && exit 0
+ [ "$((zv < fv))" -eq 1 ] && exit 1
+ zvs=${zvs#*.}
+ [ -n "$zvs" ] || exit 0
+ done
+) ; then
+ ENV_FORCE=1
+fi