aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-11 14:08:07 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-11 14:08:07 +1300
commite21b52c1f133f5c1f59f88a1bc266101577da6b3 (patch)
tree9357c1db0705a0b38b2524e709b7877b252cd47c
parentRefactor "path list" not to require a subshell (diff)
downloaddotfiles-e21b52c1f133f5c1f59f88a1bc266101577da6b3.tar.gz
dotfiles-e21b52c1f133f5c1f59f88a1bc266101577da6b3.zip
Factor out zsh ENV hack into one file
It's a bit silly to have this in ~/.profile; it doesn't need to be there for such a niche case.
-rw-r--r--sh/profile8
-rw-r--r--zsh/profile.d/zsh.sh25
2 files changed, 17 insertions, 16 deletions
diff --git a/sh/profile b/sh/profile
index 68e803ca..544ee640 100644
--- a/sh/profile
+++ b/sh/profile
@@ -13,11 +13,3 @@ if [ -f "$HOME"/.shinit ] ; then
ENV=$HOME/.shinit
export ENV
fi
-
-# If ENV_FORCE is set and we're interactive, source ENV explicitly
-# At the moment this is just for zsh-as-ksh/sh
-if [ -n "$ENV_FORCE" ] ; then
- case $- in *i*)
- [ -f "$ENV" ] && . "$ENV" ;;
- esac
-fi
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