From 556d67d82be74554a87842c89eaeb28ee91eafb1 Mon Sep 17 00:00:00 2001 From: JSap0914 Date: Tue, 16 Jun 2026 11:36:44 +0900 Subject: [PATCH] fix: correct rm --all worktree loop for bash (0-indexed arrays) _cmux_rm_all built its dirs/branches arrays with += (0-indexed in bash) but iterated with for (( i=1; i<=${#dirs[@]}; i++ )). In bash this skips the first worktree and reads an empty element at i==count, producing a blank 'Failed:' line and '1 failed'. zsh masked it (1-indexed arrays). Use 0-indexed, strict-less-than loops; identical behavior in zsh and bash. --- cmux.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmux.sh b/cmux.sh index 7a0abaf..7998136 100644 --- a/cmux.sh +++ b/cmux.sh @@ -728,7 +728,7 @@ _cmux_rm_all() { # Show what will be removed echo "This will remove ALL cmux worktrees and their branches:" echo "" - for (( i = 1; i <= ${#dirs[@]}; i++ )); do + for (( i = 0; i < ${#dirs[@]}; i++ )); do local rel_dir="${dirs[$i]#$repo_root/}" echo " $rel_dir (branch: ${branches[$i]})" done @@ -751,7 +751,7 @@ _cmux_rm_all() { # Remove each worktree echo "" local failed=0 - for (( i = 1; i <= ${#dirs[@]}; i++ )); do + for (( i = 0; i < ${#dirs[@]}; i++ )); do # Run project-specific teardown hook cd "${dirs[$i]}" if [[ -x "${dirs[$i]}/.cmux/teardown" ]]; then