From bbec3cb6af844e3f6d95bd7f28435abe0b5d21af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 3 Apr 2020 07:56:04 +0200 Subject: [PATCH] Fix zsh stalled $RANDOM variable (#247) This change references `$RANDOM` outside the subshell to refresh it for the next subshell invocation. Otherwise, subsequent runs of the function get the same value and, if run simultaneously, they may clobber each others' temp .z files. This is due to how zsh distributes RANDOM values when running inside a subshell: subshells that reference RANDOM will result in identical pseudo-random values unless the value of RANDOM is referenced or seeded in the parent shell in between subshell invocations See: http://zsh.sourceforge.net/Doc/Release/Parameters.html#index-RANDOM --- z.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/z.sh b/z.sh index f9ec16a..78f620c 100644 --- a/z.sh +++ b/z.sh @@ -229,10 +229,12 @@ if type compctl >/dev/null 2>&1; then if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then _z_precmd() { (_z --add "${PWD:a}" &) + : $RANDOM } else _z_precmd() { (_z --add "${PWD:A}" &) + : $RANDOM } fi [[ -n "${precmd_functions[(r)_z_precmd]}" ]] || {