Skip to content

Commit

Permalink
fix(init): prevent collision with other initializing sessions [#8]
Browse files Browse the repository at this point in the history
  • Loading branch information
olets committed Mar 7, 2020
1 parent dea1331 commit f02fe24
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions zsh-abbr.zsh
Expand Up @@ -884,6 +884,14 @@ _zsh_abbr_init() {
session_shwordsplit_on=true
fi

# prevent collisions with other initializing sessions
while [ -f "${TMPDIR:-/tmp}/zsh-abbr-initializing" ]; do
sleep 0.01
done

touch "${TMPDIR:-/tmp}/zsh-abbr-initializing"
chmod 600 "${TMPDIR:-/tmp}/zsh-user-abbreviations"

# Scratch files
rm "${TMPDIR:-/tmp}/zsh-user-abbreviations" 2> /dev/null
touch "${TMPDIR:-/tmp}/zsh-user-abbreviations"
Expand Down Expand Up @@ -911,6 +919,8 @@ _zsh_abbr_init() {

typeset -p ZSH_ABBR_USER_COMMANDS > "${TMPDIR:-/tmp}/zsh-user-abbreviations"
typeset -p ZSH_ABBR_USER_GLOBALS > "${TMPDIR:-/tmp}/zsh-user-global-abbreviations"

rm "${TMPDIR:-/tmp}/zsh-abbr-initializing"
}

# WIDGETS
Expand Down

0 comments on commit f02fe24

Please sign in to comment.