From e21b52c1f133f5c1f59f88a1bc266101577da6b3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 11 Dec 2018 14:08:07 +1300 Subject: 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. --- zsh/profile.d/zsh.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'zsh') 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 -- cgit v1.2.3