fix(init): clear partial hostname cache reads

Co-authored-by: robbyrussell <257+robbyrussell@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-09-07 20:46:24 +00:00
committed by GitHub
co-authored by robbyrussell
parent 65d305ad06
commit e9f6de4af6
+6 -1
View File
@@ -104,8 +104,13 @@ if [[ "$OSTYPE" = darwin* ]]; then
# (like lib/grep.zsh) and re-check sooner if $HOST changes.
__omz_host_cache="$ZSH_CACHE_DIR/localhostname"
__omz_host_cached=("$__omz_host_cache"(Nm-1))
__omz_host_key=
SHORT_HOST=
if [[ -n "$__omz_host_cached" ]]; then
{ read -r __omz_host_key && read -r SHORT_HOST } < "$__omz_host_cache"
if ! { read -r __omz_host_key && read -r SHORT_HOST } < "$__omz_host_cache"; then
__omz_host_key=
SHORT_HOST=
fi
fi
if [[ "$__omz_host_key" != "$HOST" || -z "$SHORT_HOST" ]]; then
# only cache what scutil actually answered, so a transient failure