aboutsummaryrefslogtreecommitdiff
path: root/zsh/profile.d/zsh.sh
diff options
context:
space:
mode:
Diffstat (limited to 'zsh/profile.d/zsh.sh')
-rw-r--r--zsh/profile.d/zsh.sh25
1 files changed, 17 insertions, 8 deletions
diff --git a/zsh/profile.d/zsh.sh b/zsh/profile.d/zsh.sh
index 47de6d4d..37ec8014 100644
--- a/zsh/profile.d/zsh.sh
+++ b/zsh/profile.d/zsh.sh
@@ -5,24 +5,33 @@
# ~/.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?
+# This hack is only applicable to interactive zsh invoked as sh/ksh, when ENV
+# exists, so check each of those:
+## Interactive?
+case $- in
+ *i*) ;;
+ *) return ;;
+esac
+## zsh?
[ -n "$ZSH_VERSION" ] || return
+## Invoked as sh or ksh?
case $ZSH_NAME in
sh|ksh) ;;
*) return ;;
esac
+## ENV exists?
+[ -e "$ENV" ] || return
# 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 ! (
+# we'll source $ENV ourselves, since ~/.profile probably didn't do it
+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
+ ! [ "$zv" -gt "$fv" ] || exit 1
+ ! [ "$zv" -lt "$fv" ] || exit 0
+ zvs=${ZSH_VERSION#*.}
done
) ; then
- ENV_FORCE=1
+ . "$ENV"
fi