survive broken $TMPDIR

kitty
Roman Perepelitsa 3 years ago
parent cead0349c5
commit d6f8c47761

@ -6280,8 +6280,13 @@ _p9k_dump_instant_prompt() {
out+="$cr${(pl:$((height-prompt_height))::\n:)}$terminfo[sc]$out" out+="$cr${(pl:$((height-prompt_height))::\n:)}$terminfo[sc]$out"
fi fi
fi fi
typeset -g __p9k_instant_prompt_output=${TMPDIR:-/tmp}/p10k-instant-prompt-output-${(%):-%n}-$$ if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then
{ echo -n > $__p9k_instant_prompt_output } || return local tmpdir=$TMPDIR
else
local tmpdir=/tmp
fi
typeset -g __p9k_instant_prompt_output=$tmpdir/p10k-instant-prompt-output-${(%):-%n}-$$
{ : > $__p9k_instant_prompt_output } || return
print -rn -- "${out}${esc}?2004h" || return print -rn -- "${out}${esc}?2004h" || return
if (( $+commands[stty] )); then if (( $+commands[stty] )); then
command stty -icanon 2>/dev/null command stty -icanon 2>/dev/null
@ -7802,7 +7807,12 @@ function _p9k_wrap_widgets() {
# There is no zle-line-pre-redraw in zsh < 5.3, so we have to wrap all widgets # There is no zle-line-pre-redraw in zsh < 5.3, so we have to wrap all widgets
# with key bindings. This costs extra 3ms: 1.5ms to fetch the list of widgets and # with key bindings. This costs extra 3ms: 1.5ms to fetch the list of widgets and
# another 1.5ms to wrap them. # another 1.5ms to wrap them.
local keymap tmp=${TMPDIR:-/tmp}/p10k.bindings.$sysparams[pid] if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then
local tmpdir=$TMPDIR
else
local tmpdir=/tmp
fi
local keymap tmp=$tmpdir/p10k.bindings.$sysparams[pid]
{ {
for keymap in $keymaps; do bindkey -M $keymap; done >$tmp for keymap in $keymaps; do bindkey -M $keymap; done >$tmp
local -aU widget_list=( local -aU widget_list=(
@ -8259,7 +8269,7 @@ _p9k_must_init() {
[[ $sig == $_p9k__param_sig ]] && return 1 [[ $sig == $_p9k__param_sig ]] && return 1
_p9k_deinit _p9k_deinit
fi fi
_p9k__param_pat=$'v133\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1' _p9k__param_pat=$'v134\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1'
_p9k__param_pat+=$__p9k_force_term_shell_integration$'\1' _p9k__param_pat+=$__p9k_force_term_shell_integration$'\1'
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1' _p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1'
_p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1' _p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'

@ -1537,9 +1537,16 @@ function ask_config_overwrite() {
case $choice in case $choice in
r) return 1;; r) return 1;;
y) y)
config_backup="$(mktemp ${TMPDIR:-/tmp}/$__p9k_cfg_basename.XXXXXXXXXX)" || quit -c if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then
local tmpdir=$TMPDIR
local tmpdir_u='$TMPDIR'
else
local tmpdir=/tmp
local tmpdir_u=/tmp
fi
config_backup="$(mktemp $tmpdir/$__p9k_cfg_basename.XXXXXXXXXX)" || quit -c
cp $__p9k_cfg_path $config_backup || quit -c cp $__p9k_cfg_path $config_backup || quit -c
config_backup_u=${${TMPDIR:+\$TMPDIR}:-/tmp}/${(q-)config_backup:t} config_backup_u=$tmpdir_u/${(q-)config_backup:t}
;; ;;
esac esac
return 0 return 0
@ -1600,16 +1607,23 @@ function ask_zshrc_edit() {
y) y)
write_zshrc=1 write_zshrc=1
if [[ -n $zshrc_content ]]; then if [[ -n $zshrc_content ]]; then
zshrc_backup="$(mktemp ${TMPDIR:-/tmp}/.zshrc.XXXXXXXXXX)" || quit -c if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then
cp -p $__p9k_zshrc $zshrc_backup || quit -c local tmpdir=$TMPDIR
local tmpdir_u='$TMPDIR'
else
local tmpdir=/tmp
local tmpdir_u=/tmp
fi
zshrc_backup="$(mktemp $tmpdir/.zshrc.XXXXXXXXXX)" || quit -c
cp -p $__p9k_zshrc $zshrc_backup || quit -c
local -i writable=1 local -i writable=1
if [[ ! -w $zshrc_backup ]]; then if [[ ! -w $zshrc_backup ]]; then
chmod u+w -- $zshrc_backup || quit -c chmod u+w -- $zshrc_backup || quit -c
writable=0 writable=0
fi fi
print -r -- $zshrc_content >$zshrc_backup || quit -c print -r -- $zshrc_content >$zshrc_backup || quit -c
(( writable )) || chmod u-w -- $zshrc_backup || quit -c (( writable )) || chmod u-w -- $zshrc_backup || quit -c
zshrc_backup_u=${${TMPDIR:+\$TMPDIR}:-/tmp}/${(q-)zshrc_backup:t} zshrc_backup_u=$tmpdir_u/${(q-)zshrc_backup:t}
fi fi
;; ;;
esac esac

@ -181,7 +181,13 @@ function _p9k_worker_start() {
setopt monitor || return setopt monitor || return
{ {
[[ -n $_p9k__worker_resp_fd ]] && return [[ -n $_p9k__worker_resp_fd ]] && return
_p9k__worker_file_prefix=${TMPDIR:-/tmp}/p10k.worker.$EUID.$sysparams[pid].$EPOCHSECONDS
if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then
local tmpdir=$TMPDIR
else
local tmpdir=/tmp
fi
_p9k__worker_file_prefix=$tmpdir/p10k.worker.$EUID.$sysparams[pid].$EPOCHSECONDS
sysopen -r -o cloexec -u _p9k__worker_resp_fd <( sysopen -r -o cloexec -u _p9k__worker_resp_fd <(
exec 0</dev/null exec 0</dev/null

Loading…
Cancel
Save