From 10c307f405705afc2335521e9fbb397b50f2fee7 Mon Sep 17 00:00:00 2001 From: Eric Nielsen <4120606+ericbn@users.noreply.github.com> Date: Sat, 6 May 2023 19:38:25 -0500 Subject: [PATCH] Use `${HOME}` in generated static init.zsh script Fixes #509 --- src/stage2/29_zimfw_build_init.zsh.erb | 6 +++--- src/stage2/30_zmodule.zsh.erb | 9 +++++---- zimfw.zsh | 17 +++++++++-------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/stage2/29_zimfw_build_init.zsh.erb b/src/stage2/29_zimfw_build_init.zsh.erb index 381776a..f0bc9b7 100644 --- a/src/stage2/29_zimfw_build_init.zsh.erb +++ b/src/stage2/29_zimfw_build_init.zsh.erb @@ -5,8 +5,8 @@ _zimfw_build_init() { command mv -f ${ztarget}{,.old} || return 1 fi _zimfw_mv =( - print -R "zimfw() { source ${(q-)ZIM_HOME}/zimfw.zsh \"\${@}\" }" - print -R "zmodule() { source ${(q-)ZIM_HOME}/zimfw.zsh \"\${@}\" }" + print -R 'zimfw() { source '${${(qqq)ZIM_HOME}/${HOME}/\${HOME}}'/zimfw.zsh "${@}" }' + print -R 'zmodule() { source '${${(qqq)ZIM_HOME}/${HOME}/\${HOME}}'/zimfw.zsh "${@}" }' local zroot_dir zpre local -a zif_functions zif_cmds zroot_functions zroot_cmds local -a zfunctions=(${_zfunctions}) zcmds=(${_zcmds}) @@ -22,7 +22,7 @@ _zimfw_build_init() { fi done zpre=$'*\0' - if (( ${#_zfpaths} )) print 'fpath=('${(q-)${_zfpaths#${~zpre}}:a}' ${fpath})' + if (( ${#_zfpaths} )) print 'fpath=('${${(qqq)${_zfpaths#${~zpre}}:a}/${HOME}/\${HOME}}' ${fpath})' if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}} for zroot_dir in ${_zroot_dirs}; do zpre=${zroot_dir}$'\0' diff --git a/src/stage2/30_zmodule.zsh.erb b/src/stage2/30_zmodule.zsh.erb index 9535ef7..e7beb2e 100644 --- a/src/stage2/30_zmodule.zsh.erb +++ b/src/stage2/30_zmodule.zsh.erb @@ -179,11 +179,11 @@ Per-call initialization options: shift zarg=${1} if [[ ${zarg} != /* ]] zarg=${zroot_dir}/${zarg} - zcmds+=("source ${(q-)zarg:a}") + zcmds+=('source '${(qqq)zarg:a}) ;; -c|--cmd) shift - zcmds+=(${1//{}/${(q-)zroot_dir:a}}) + zcmds+=(${1//{}/${(qqq)zroot_dir:a}}) ;; -d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;; *) @@ -211,11 +211,11 @@ Per-call initialization options: local -ra prezto_scripts=(${zroot_dir}/init.zsh(N)) if (( ${#zfpaths} && ${#prezto_scripts} )); then # this follows the prezto module format, no need to check for other scripts - zcmds=('source '${(q-)^prezto_scripts:a}) + zcmds=('source '${(qqq)^prezto_scripts:a}) else # get script with largest size (descending `O`rder by `L`ength, and return only `[1]` first) local -ra zscripts=(${zroot_dir}/(init.zsh|(${zname:t}|${zroot_dir:t}).(zsh|plugin.zsh|zsh-theme|sh))(NOL[1])) - zcmds=('source '${(q-)^zscripts:a}) + zcmds=('source '${(qqq)^zscripts:a}) fi fi if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then @@ -225,6 +225,7 @@ Per-call initialization options: local -r zpre=${zroot_dir}$'\0' _zfpaths+=(${zpre}${^zfpaths}) _zfunctions+=(${zpre}${^zfunctions}) + zcmds=(${zcmds/${HOME}/\${HOME}}) _zcmds+=(${zpre}${^zcmds}) fi } diff --git a/zimfw.zsh b/zimfw.zsh index 47de7d5..92596ff 100644 --- a/zimfw.zsh +++ b/zimfw.zsh @@ -57,8 +57,8 @@ _zimfw_build_init() { command mv -f ${ztarget}{,.old} || return 1 fi _zimfw_mv =( - print -R "zimfw() { source ${(q-)ZIM_HOME}/zimfw.zsh \"\${@}\" }" - print -R "zmodule() { source ${(q-)ZIM_HOME}/zimfw.zsh \"\${@}\" }" + print -R 'zimfw() { source '${${(qqq)ZIM_HOME}/${HOME}/\${HOME}}'/zimfw.zsh "${@}" }' + print -R 'zmodule() { source '${${(qqq)ZIM_HOME}/${HOME}/\${HOME}}'/zimfw.zsh "${@}" }' local zroot_dir zpre local -a zif_functions zif_cmds zroot_functions zroot_cmds local -a zfunctions=(${_zfunctions}) zcmds=(${_zcmds}) @@ -74,7 +74,7 @@ _zimfw_build_init() { fi done zpre=$'*\0' - if (( ${#_zfpaths} )) print 'fpath=('${(q-)${_zfpaths#${~zpre}}:a}' ${fpath})' + if (( ${#_zfpaths} )) print 'fpath=('${${(qqq)${_zfpaths#${~zpre}}:a}/${HOME}/\${HOME}}' ${fpath})' if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}} for zroot_dir in ${_zroot_dirs}; do zpre=${zroot_dir}$'\0' @@ -291,11 +291,11 @@ Per-call initialization options: shift zarg=${1} if [[ ${zarg} != /* ]] zarg=${zroot_dir}/${zarg} - zcmds+=("source ${(q-)zarg:a}") + zcmds+=('source '${(qqq)zarg:a}) ;; -c|--cmd) shift - zcmds+=(${1//{}/${(q-)zroot_dir:a}}) + zcmds+=(${1//{}/${(qqq)zroot_dir:a}}) ;; -d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;; *) @@ -323,11 +323,11 @@ Per-call initialization options: local -ra prezto_scripts=(${zroot_dir}/init.zsh(N)) if (( ${#zfpaths} && ${#prezto_scripts} )); then # this follows the prezto module format, no need to check for other scripts - zcmds=('source '${(q-)^prezto_scripts:a}) + zcmds=('source '${(qqq)^prezto_scripts:a}) else # get script with largest size (descending `O`rder by `L`ength, and return only `[1]` first) local -ra zscripts=(${zroot_dir}/(init.zsh|(${zname:t}|${zroot_dir:t}).(zsh|plugin.zsh|zsh-theme|sh))(NOL[1])) - zcmds=('source '${(q-)^zscripts:a}) + zcmds=('source '${(qqq)^zscripts:a}) fi fi if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then @@ -337,6 +337,7 @@ Per-call initialization options: local -r zpre=${zroot_dir}$'\0' _zfpaths+=(${zpre}${^zfpaths}) _zfunctions+=(${zpre}${^zfunctions}) + zcmds=(${zcmds/${HOME}/\${HOME}}) _zcmds+=(${zpre}${^zcmds}) fi } @@ -433,7 +434,7 @@ _zimfw_compile() { } _zimfw_info() { - print -R 'zimfw version: '${_zversion}' (built at 2023-04-01 01:32:16 UTC, previous commit is 5db1155)' + print -R 'zimfw version: '${_zversion}' (built at 2023-05-04 00:03:05 UTC, previous commit is db96076)' local zparam for zparam in LANG ${(Mk)parameters:#LC_*} OSTYPE TERM TERM_PROGRAM TERM_PROGRAM_VERSION ZIM_HOME ZSH_VERSION; do print -R ${(r.22....:.)zparam}${(P)zparam}