@@ -686,56 +686,67 @@ update_specific_agent() {
686686 esac
687687}
688688
689- update_all_existing_agents () {
690- local found_agent=false
691- local _updated_paths=()
692-
693- # Helper: skip non-existent files and files already updated (dedup by
694- # realpath so that variables pointing to the same file — e.g. AMP_FILE,
695- # KIRO_FILE, BOB_FILE all resolving to AGENTS_FILE — are only written once).
696- # Uses a linear array instead of associative array for bash 3.2 compatibility.
697- update_if_new () {
698- local file=" $1 " name=" $2 "
699- [[ -f " $file " ]] || return 0
700- local real_path
701- real_path=$( realpath " $file " 2> /dev/null || echo " $file " )
702- local p
703- if [[ ${# _updated_paths[@]} -gt 0 ]]; then
704- for p in " ${_updated_paths[@]} " ; do
705- [[ " $p " == " $real_path " ]] && return 0
706- done
707- fi
708- update_agent_file " $file " " $name " || return 1
709- _updated_paths+=(" $real_path " )
710- found_agent=true
711- }
689+ # Helper: skip non-existent files and files already updated (dedup by
690+ # realpath so that variables pointing to the same file — e.g. AMP_FILE,
691+ # KIRO_FILE, BOB_FILE all resolving to AGENTS_FILE — are only written once).
692+ # Uses a linear array instead of associative array for bash 3.2 compatibility.
693+ # Note: defined at top level because bash 3.2 does not support true
694+ # nested/local functions. _updated_paths, _found_agent, and _all_ok are
695+ # initialised exclusively inside update_all_existing_agents so that
696+ # sourcing this script has no side effects on the caller's environment.
697+
698+ _update_if_new () {
699+ local file=" $1 " name=" $2 "
700+ [[ -f " $file " ]] || return 0
701+ local real_path
702+ real_path=$( realpath " $file " 2> /dev/null || echo " $file " )
703+ local p
704+ if [[ ${# _updated_paths[@]} -gt 0 ]]; then
705+ for p in " ${_updated_paths[@]} " ; do
706+ [[ " $p " == " $real_path " ]] && return 0
707+ done
708+ fi
709+ # Record the file as seen before attempting the update so that:
710+ # (a) aliases pointing to the same path are not retried on failure
711+ # (b) _found_agent reflects file existence, not update success
712+ _updated_paths+=(" $real_path " )
713+ _found_agent=true
714+ update_agent_file " $file " " $name "
715+ }
712716
713- update_if_new " $CLAUDE_FILE " " Claude Code"
714- update_if_new " $GEMINI_FILE " " Gemini CLI"
715- update_if_new " $COPILOT_FILE " " GitHub Copilot"
716- update_if_new " $CURSOR_FILE " " Cursor IDE"
717- update_if_new " $QWEN_FILE " " Qwen Code"
718- update_if_new " $AGENTS_FILE " " Codex/opencode"
719- update_if_new " $AMP_FILE " " Amp"
720- update_if_new " $KIRO_FILE " " Kiro CLI"
721- update_if_new " $BOB_FILE " " IBM Bob"
722- update_if_new " $WINDSURF_FILE " " Windsurf"
723- update_if_new " $KILOCODE_FILE " " Kilo Code"
724- update_if_new " $AUGGIE_FILE " " Auggie CLI"
725- update_if_new " $ROO_FILE " " Roo Code"
726- update_if_new " $CODEBUDDY_FILE " " CodeBuddy CLI"
727- update_if_new " $SHAI_FILE " " SHAI"
728- update_if_new " $TABNINE_FILE " " Tabnine CLI"
729- update_if_new " $QODER_FILE " " Qoder CLI"
730- update_if_new " $AGY_FILE " " Antigravity"
731- update_if_new " $VIBE_FILE " " Mistral Vibe"
732- update_if_new " $KIMI_FILE " " Kimi Code"
717+ update_all_existing_agents () {
718+ _found_agent=false
719+ _updated_paths=()
720+ local _all_ok=true
721+
722+ _update_if_new " $CLAUDE_FILE " " Claude Code" || _all_ok=false
723+ _update_if_new " $GEMINI_FILE " " Gemini CLI" || _all_ok=false
724+ _update_if_new " $COPILOT_FILE " " GitHub Copilot" || _all_ok=false
725+ _update_if_new " $CURSOR_FILE " " Cursor IDE" || _all_ok=false
726+ _update_if_new " $QWEN_FILE " " Qwen Code" || _all_ok=false
727+ _update_if_new " $AGENTS_FILE " " Codex/opencode" || _all_ok=false
728+ _update_if_new " $AMP_FILE " " Amp" || _all_ok=false
729+ _update_if_new " $KIRO_FILE " " Kiro CLI" || _all_ok=false
730+ _update_if_new " $BOB_FILE " " IBM Bob" || _all_ok=false
731+ _update_if_new " $WINDSURF_FILE " " Windsurf" || _all_ok=false
732+ _update_if_new " $KILOCODE_FILE " " Kilo Code" || _all_ok=false
733+ _update_if_new " $AUGGIE_FILE " " Auggie CLI" || _all_ok=false
734+ _update_if_new " $ROO_FILE " " Roo Code" || _all_ok=false
735+ _update_if_new " $CODEBUDDY_FILE " " CodeBuddy CLI" || _all_ok=false
736+ _update_if_new " $SHAI_FILE " " SHAI" || _all_ok=false
737+ _update_if_new " $TABNINE_FILE " " Tabnine CLI" || _all_ok=false
738+ _update_if_new " $QODER_FILE " " Qoder CLI" || _all_ok=false
739+ _update_if_new " $AGY_FILE " " Antigravity" || _all_ok=false
740+ _update_if_new " $VIBE_FILE " " Mistral Vibe" || _all_ok=false
741+ _update_if_new " $KIMI_FILE " " Kimi Code" || _all_ok=false
733742
734743 # If no agent files exist, create a default Claude file
735- if [[ " $found_agent " == false ]]; then
744+ if [[ " $_found_agent " == false ]]; then
736745 log_info " No existing agent files found, creating default Claude file..."
737746 update_agent_file " $CLAUDE_FILE " " Claude Code" || return 1
738747 fi
748+
749+ [[ " $_all_ok " == true ]]
739750}
740751print_summary () {
741752 echo
0 commit comments