more robust zcompile

pull/527/head
romkatv 5 years ago
parent e5f2d39a16
commit d9da275e9e

@ -3873,7 +3873,7 @@ function _p9k_read_pyenv_like_version_file() {
else else
local fd content local fd content
{ {
{ sysopen -r -u fd $1 && sysread -i $fd -s 1024 content } 2>/dev/null { sysopen -r -u fd -- $1 && sysread -i $fd -s 1024 content } 2>/dev/null
} always { } always {
[[ -n $fd ]] && exec {fd}>&- [[ -n $fd ]] && exec {fd}>&-
} }
@ -5161,7 +5161,7 @@ _p9k_dump_instant_prompt() {
if [[ ! -e $root_file ]]; then if [[ ! -e $root_file ]]; then
local tmp=$root_file.tmp.$$ local tmp=$root_file.tmp.$$
local -i fd local -i fd
sysopen -a -o creat,trunc -u fd $tmp || return sysopen -a -m 600 -o creat,trunc -u fd -- $tmp || return
{ {
[[ $TERM_PROGRAM == Hyper ]] && local hyper='==' || local hyper='!=' [[ $TERM_PROGRAM == Hyper ]] && local hyper='==' || local hyper='!='
local -a display_v=("${_p9k__display_v[@]}") local -a display_v=("${_p9k__display_v[@]}")
@ -5440,18 +5440,34 @@ _p9k_dump_instant_prompt() {
} always { } always {
exec {fd}>&- exec {fd}>&-
} }
{
(( ! $? )) || return
zf_mv -f $tmp $root_file || return zf_mv -f $tmp $root_file || return
zcompile -R $root_file || return zcompile -R -- $tmp.zwc $root_file || return
zf_mv -f -- $tmp.zwc $root_file.zwc || return
} always {
(( $? )) && zf_rm -f -- $tmp $tmp.zwc 2>/dev/null
}
fi fi
local tmp=$prompt_file.tmp.$$ local tmp=$prompt_file.tmp.$$
zf_mv -f $prompt_file $tmp 2>/dev/null zf_mv -f -- $prompt_file $tmp 2>/dev/null
if [[ "$(<$prompt_file)" == *$'\x1e'$_p9k__instant_prompt_sig$'\x1f'* ]] 2>/dev/null; then if [[ "$(<$prompt_file)" == *$'\x1e'$_p9k__instant_prompt_sig$'\x1f'* ]] 2>/dev/null; then
echo -n >$tmp || return echo -n >$tmp || return
fi fi
{ print -rn -- $'\x1e'$_p9k__instant_prompt_sig$'\x1f'${(pj:\x1f:)_p9k_t}$'\x1f'$_p9k__instant_prompt >>$tmp } 2>/dev/null || return local -i fd
zf_mv -f $tmp $prompt_file 2>/dev/null || return sysopen -a -m 600 -o creat -u fd -- $tmp || return
{
{
print -rnu $fd -- $'\x1e'$_p9k__instant_prompt_sig$'\x1f'${(pj:\x1f:)_p9k_t}$'\x1f'$_p9k__instant_prompt || return
} always {
exec {fd}>&-
}
zf_mv -f -- $tmp $prompt_file || return
} always {
(( $? )) && zf_rm -f -- $tmp 2>/dev/null
}
} }
typeset -gi __p9k_sh_glob typeset -gi __p9k_sh_glob
@ -5505,11 +5521,12 @@ _p9k_save_status() {
function _p9k_dump_state() { function _p9k_dump_state() {
local dir=${__p9k_dump_file:h} local dir=${__p9k_dump_file:h}
[[ -d $dir ]] || mkdir -p $dir || return [[ -d $dir ]] || mkdir -p -- $dir || return
[[ -w $dir ]] || return [[ -w $dir ]] || return
local tmp=$__p9k_dump_file.$$-$EPOCHREALTIME-$RANDOM local tmp=$__p9k_dump_file.tmp.$$
local -i fd local -i fd
sysopen -a -m 600 -o creat,trunc -u fd $tmp || return sysopen -a -m 600 -o creat,trunc -u fd -- $tmp || return
{
{ {
typeset -g __p9k_cached_param_pat=$_p9k__param_pat typeset -g __p9k_cached_param_pat=$_p9k__param_pat
typeset -g __p9k_cached_param_sig=$_p9k__param_sig typeset -g __p9k_cached_param_sig=$_p9k__param_sig
@ -5522,8 +5539,12 @@ function _p9k_dump_state() {
} always { } always {
exec {fd}>&- exec {fd}>&-
} }
zf_mv -f $tmp $__p9k_dump_file || return zf_mv -f -- $tmp $__p9k_dump_file || return
zcompile -R $__p9k_dump_file zcompile -R -- $tmp.zwc $__p9k_dump_file || return
zf_mv -f -- $tmp.zwc $__p9k_dump_file.zwc || return
} always {
(( $? )) && zf_rm -f -- $tmp $tmp.zwc 2>/dev/null
}
} }
function _p9k_restore_state() { function _p9k_restore_state() {
@ -6657,7 +6678,7 @@ function _p9k_wrap_widgets() {
${${${(f)"$(<$tmp)"}##* }:#(*\"|.*)} ${${${(f)"$(<$tmp)"}##* }:#(*\"|.*)}
) )
} always { } always {
zf_rm -f $tmp zf_rm -f -- $tmp
} }
fi fi
local widget local widget
@ -7827,7 +7848,7 @@ zmodload -F zsh/net/socket b:zsocket
zmodload -F zsh/files b:zf_mv b:zf_rm zmodload -F zsh/files b:zf_mv b:zf_rm
if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_prompt_dump_file ]]; then if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_prompt_dump_file ]]; then
zf_rm -f $__p9k_instant_prompt_dump_file 2>/dev/null zf_rm -f -- $__p9k_instant_prompt_dump_file 2>/dev/null
fi fi
if [[ $+__p9k_instant_prompt_sourced == 1 && $__p9k_instant_prompt_sourced != $__p9k_instant_prompt_version ]]; then if [[ $+__p9k_instant_prompt_sourced == 1 && $__p9k_instant_prompt_sourced != $__p9k_instant_prompt_version ]]; then

@ -44,10 +44,17 @@
_p9k_preinit _p9k_preinit
fi fi
typeset -gr __p9k_sourced=6 typeset -gr __p9k_sourced=6
if [[ -w $__p9k_root_dir && -w $__p9k_root_dir/internal && -w $__p9k_root_dir/gitstatus && ${(%):-%#} == % ]]; then if [[ -w $__p9k_root_dir && -w $__p9k_root_dir/internal && -w $__p9k_root_dir/gitstatus ]]; then
local f local f
for f in $__p9k_root_dir/{powerlevel9k.zsh-theme,powerlevel10k.zsh-theme,internal/p10k.zsh,internal/icons.zsh,internal/configure.zsh,internal/worker.zsh,internal/parser.zsh,gitstatus/gitstatus.plugin.zsh}; do for f in $__p9k_root_dir/{powerlevel9k.zsh-theme,powerlevel10k.zsh-theme,internal/p10k.zsh,internal/icons.zsh,internal/configure.zsh,internal/worker.zsh,internal/parser.zsh,gitstatus/gitstatus.plugin.zsh}; do
[[ $f.zwc -nt $f ]] || zcompile -R $f [[ $f.zwc -nt $f ]] && continue
zmodload -F zsh/files b:zf_mv b:zf_rm
local tmp=$f.tmp.$$.zwc
{
zcompile -R -- $tmp $f && zf_mv -f -- $tmp $f.zwc
} always {
(( $? )) && zf_rm -f -- $tmp
}
done done
fi fi
source $__p9k_root_dir/internal/p10k.zsh || true source $__p9k_root_dir/internal/p10k.zsh || true

Loading…
Cancel
Save