Skip to content

Commit 97ccd25

Browse files
committed
fix(shell): build project_open cache async only in interactive shells
1 parent 0561964 commit 97ccd25

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

shell/aliases

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,11 @@ _project_open_complete_bash() {
460460
if [[ -n "${BASH_VERSION:-}" ]]; then
461461
complete -F _project_open_complete_bash project_open
462462
complete -F _project_open_complete_bash po
463-
# Rebuild the project cache in the background, detached so no job message prints.
464-
( _project_open_build_cache & ) >/dev/null 2>&1
463+
# Rebuild the project cache in the background, detached so no job message
464+
# prints. Interactive only, so sourcing in scripts/tests spawns nothing.
465+
if [[ $- == *i* ]]; then
466+
( _project_open_build_cache & ) >/dev/null 2>&1
467+
fi
465468
fi
466469

467470
if [[ -n "${ZSH_VERSION:-}" ]]; then
@@ -504,7 +507,10 @@ if [[ -n "${ZSH_VERSION:-}" ]]; then
504507
else
505508
add-zsh-hook precmd _project_open_register_zsh
506509
fi
507-
_project_open_build_cache &!'
510+
# Interactive only, so a non-interactive `zsh -c "source ..."` spawns no job.
511+
if [[ -o interactive ]]; then
512+
_project_open_build_cache &!
513+
fi'
508514
fi
509515

510516
project_edit() {

0 commit comments

Comments
 (0)