From a227f134a5d0746e099c9895be758b2f1e0b439b Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Tue, 3 Dec 2019 07:07:59 -0500 Subject: [PATCH] Source .zimrc twice when installing/updating Once before installing/updating to prepare _zmodule_xargs, and once after modules are updated, so functions and scripts can be found inside them. Installation of Zim from scratch was failing because all modules are empty at first. --- src/stage2/30_zmodule.zsh.erb | 37 +++++++++++---------- src/stage2/31_zimfw_source_zimrc.zsh.erb | 1 + src/stage2/80_zimfw.zsh.erb | 4 +-- zimfw.zsh | 42 +++++++++++++----------- 4 files changed, 46 insertions(+), 38 deletions(-) diff --git a/src/stage2/30_zmodule.zsh.erb b/src/stage2/30_zmodule.zsh.erb index 51506bf..190786b 100644 --- a/src/stage2/30_zmodule.zsh.erb +++ b/src/stage2/30_zmodule.zsh.erb @@ -96,24 +96,27 @@ Startup options: esac shift done - if (( zdisabled )); then - _zdisableds+=(${zmodule}) + if (( _zprepare_xargs )); then + if (( ! zfrozen )); then + _zmodules_xargs+=${zmodule}$'\0'${zdir}$'\0'${zurl}$'\0'${ztype}$'\0'${zrev}$'\0'${_zquiet}$'\0' + fi else - (( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF)) - if (( ! ${#zfunctions} )); then - # _* functions are autoloaded by compinit - # prompt_*_setup functions are autoloaded by promptinit - zfunctions+=(${^zfpaths}/^(*.*|_*|prompt_*_setup)(N-.:t)) + if (( zdisabled )); then + _zdisableds+=(${zmodule}) + else + (( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF)) + if (( ! ${#zfunctions} )); then + # _* functions are autoloaded by compinit + # prompt_*_setup functions are autoloaded by promptinit + zfunctions+=(${^zfpaths}/^(*.*|_*|prompt_*_setup)(N-.:t)) + fi + if (( ! ${#zscripts} )); then + zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1])) + fi + _zfpaths+=(${zfpaths}) + _zfunctions+=(${zfunctions}) + _zscripts+=(${zscripts}) + _zmodules+=(${zmodule}) fi - if (( ! ${#zscripts} )); then - zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1])) - fi - _zfpaths+=(${zfpaths}) - _zfunctions+=(${zfunctions}) - _zscripts+=(${zscripts}) - _zmodules+=(${zmodule}) - fi - if (( ! zfrozen )); then - _zmodules_xargs+=${zmodule}$'\0'${zdir}$'\0'${zurl}$'\0'${ztype}$'\0'${zrev}$'\0'${_zquiet}$'\0' fi } diff --git a/src/stage2/31_zimfw_source_zimrc.zsh.erb b/src/stage2/31_zimfw_source_zimrc.zsh.erb index 7232db2..1a331ab 100644 --- a/src/stage2/31_zimfw_source_zimrc.zsh.erb +++ b/src/stage2/31_zimfw_source_zimrc.zsh.erb @@ -1,4 +1,5 @@ _zimfw_source_zimrc() { + local -ri _zprepare_xargs=${1} local -i _zfailed=0 if ! source <%= home %>/.zimrc || (( _zfailed )); then print -u2 -PR "%F{red}✗ Failed to source <%= home %>/.zimrc%f" diff --git a/src/stage2/80_zimfw.zsh.erb b/src/stage2/80_zimfw.zsh.erb index 0b08c98..fe801e1 100644 --- a/src/stage2/80_zimfw.zsh.erb +++ b/src/stage2/80_zimfw.zsh.erb @@ -56,12 +56,12 @@ Options: compile|login-init) _zimfw_source_zimrc && _zimfw_compile ${2} ;; info) _zimfw_info ;; install|update) - _zimfw_source_zimrc || return 1 + _zimfw_source_zimrc 1 || return 1 print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \ if (( ! _zquiet )); then print -PR "%F{green}✓%f Done with ${1}. Restart your terminal for any changes to take effect." fi && \ - _zimfw_build && _zimfw_compile ${2} + _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} ;; upgrade) _zimfw_upgrade ;; *) diff --git a/zimfw.zsh b/zimfw.zsh index 5afee7e..38584da 100644 --- a/zimfw.zsh +++ b/zimfw.zsh @@ -171,29 +171,33 @@ Startup options: esac shift done - if (( zdisabled )); then - _zdisableds+=(${zmodule}) + if (( _zprepare_xargs )); then + if (( ! zfrozen )); then + _zmodules_xargs+=${zmodule}$'\0'${zdir}$'\0'${zurl}$'\0'${ztype}$'\0'${zrev}$'\0'${_zquiet}$'\0' + fi else - (( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF)) - if (( ! ${#zfunctions} )); then - # _* functions are autoloaded by compinit - # prompt_*_setup functions are autoloaded by promptinit - zfunctions+=(${^zfpaths}/^(*.*|_*|prompt_*_setup)(N-.:t)) + if (( zdisabled )); then + _zdisableds+=(${zmodule}) + else + (( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF)) + if (( ! ${#zfunctions} )); then + # _* functions are autoloaded by compinit + # prompt_*_setup functions are autoloaded by promptinit + zfunctions+=(${^zfpaths}/^(*.*|_*|prompt_*_setup)(N-.:t)) + fi + if (( ! ${#zscripts} )); then + zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1])) + fi + _zfpaths+=(${zfpaths}) + _zfunctions+=(${zfunctions}) + _zscripts+=(${zscripts}) + _zmodules+=(${zmodule}) fi - if (( ! ${#zscripts} )); then - zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1])) - fi - _zfpaths+=(${zfpaths}) - _zfunctions+=(${zfunctions}) - _zscripts+=(${zscripts}) - _zmodules+=(${zmodule}) - fi - if (( ! zfrozen )); then - _zmodules_xargs+=${zmodule}$'\0'${zdir}$'\0'${zurl}$'\0'${ztype}$'\0'${zrev}$'\0'${_zquiet}$'\0' fi } _zimfw_source_zimrc() { + local -ri _zprepare_xargs=${1} local -i _zfailed=0 if ! source ${ZDOTDIR:-${HOME}}/.zimrc || (( _zfailed )); then print -u2 -PR "%F{red}✗ Failed to source ${ZDOTDIR:-${HOME}}/.zimrc%f" @@ -416,12 +420,12 @@ fi compile|login-init) _zimfw_source_zimrc && _zimfw_compile ${2} ;; info) _zimfw_info ;; install|update) - _zimfw_source_zimrc || return 1 + _zimfw_source_zimrc 1 || return 1 print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \ if (( ! _zquiet )); then print -PR "%F{green}✓%f Done with ${1}. Restart your terminal for any changes to take effect." fi && \ - _zimfw_build && _zimfw_compile ${2} + _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} ;; upgrade) _zimfw_upgrade ;; *)