[Bug] Infinite loop in zsh sed script generation during code synthesis

Resolved 💬 3 comments Opened Apr 23, 2026 by shrewdacumen Closed Apr 27, 2026

Bug Description
infinite loop of logical bug during zsh sed scripting. The only solution was 'you should start making the script from sratch'.

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.108
  • Feedback ID: 4b14150b-82f0-4245-a70d-fc2c2dc51819

Errors

[]

diff --git a/.ztranscript b/.ztranscript
index 8ca351f..9d1034f 100644
--- a/.ztranscript
+++ b/.ztranscript
@@ -24,30 +24,16 @@ echo "--- $0 ---"

whisper-ko-fix() {

  • if [[ $# -eq 0 ]]; then
  • echo "Usage: whisper-ko-fix <file> [file ...]"
  • return 1
  • fi
  • local file tmp checksum_before checksum_after
  • # ${file:h} = dirname, ${file:t} = basename — native zsh path modifiers, no subshell, no xtrace noise.
  • [[ $# -eq 0 ]] && { echo "Usage: whisper-ko-fix <file> [file ...]"; return 1; }
  • local file tmp sum1 sum2

for file in "$@"; do

  • if [[ ! -f "$file" ]]; then
  • echo "whisper-ko-fix: file not found: $file"
  • continue
  • fi
  • # Skip numbered duplicates (e.g. "transcript 2.txt") — garbage created by prior bugs.
  • if [[ "$(basename "$file")" =~ ' [0-9]+\.txt$' ]]; then
  • echo "whisper-ko-fix: skipping numbered duplicate: $file"
  • continue
  • fi
  • # Temp file lives in the same dir as $file → mv is an atomic same-dir rename,
  • # never a cross-directory copy that can trigger iCloud/Finder conflict numbering.
  • local file_dir
  • file_dir=$(dirname "$file")
  • if ! tmp=$(mktemp "${file_dir}/.wkf_XXXXXX" 2>/dev/null); then
  • echo "whisper-ko-fix: mktemp failed in dir: $file_dir — skipping: $file"
  • continue
  • fi
  • checksum_before=$(md5 -q "$file")
  • [[ ! -f "$file" ]] && { echo "whisper-ko-fix: not found: $file"; continue; }
  • # Skip macOS copy-numbered duplicates (single digit 2–9 only; year suffixes like " 26.txt" are 2-digit — safe).
  • [[ ${file:t} =~ ' [2-9]\.txt$' ]] && continue
  • # Temp file in same dir → atomic same-dir rename, never cross-device copy that triggers iCloud conflict numbering.
  • tmp=$(mktemp "${file:h}/.wkf_XXXXXX" 2>/dev/null) || { echo "whisper-ko-fix: mktemp failed: $file"; continue; }
  • sum1=$(md5 -q "$file")

LC_ALL=C sed -E \
-e 's/각스탈/각시탈/g' \
-e 's/감첨/감청/g' \
@@ -87,7 +73,7 @@ whisper-ko-fix() {
-e 's/일거소통/일거소탕/g' \
-e 's/일루미테이트/Illuminati/g' \
-e 's/자금만까지/자금망까지/g' \

  • -e 's/자금주/자금줄/' \
  • -e 's/자금주/자금줄/g' \

-e 's/자파/좌파/g' \
-e 's/(장동역|장동영)/장동혁/g' \
-e 's/전보전/정보전/g' \
@@ -114,9 +100,9 @@ whisper-ko-fix() {
-e 's/호성구/고성국/g' \
-e 's/화이트[[:space:]]?앳/white hat/g' \
-e '/ANE inference operation failed.*EvaluateANERequest/d' \

  • "$file" > "$tmp" && mv "$tmp" "$file" || { rm -f "$tmp"; echo "whisper-ko-fix: FAILED (sed or mv) — tmp=$tmp file=$file"; }
  • checksum_after=$(md5 -q "$file")
  • [[ "$checksum_before" != "$checksum_after" ]] && echo "✓ modified: $file"
  • "$file" > "$tmp" && mv "$tmp" "$file" || { rm -f "$tmp"; echo "whisper-ko-fix: FAILED: $file"; continue; }
  • sum2=$(md5 -q "$file")
  • [[ $sum1 != $sum2 ]] && echo "✓ $file"

done
}

  • My Verdict:

Claude-Code could not fully understand the macOS's automatic file creation esp. when there is pre-existing files with the same name.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗