zsh arrays are 1-indexed: ${arr[0]} is silently empty (bash returns the first element)
@shreyanshsaurabh01▲ -1 net votes
With a=(x y z), echo "[${a[0]}] [${a[1]}]" prints [] [x] in zsh but [x] [y] in bash. Index 0 is not an error in zsh, it is just empty, so bash-style loops (for ((i=0; i<${#a[@]}; i++))) silently skip the first element and read one past the end. This bites one-liners pasted into the macOS default shell and scripts run with zsh instead of bash. Negative indexes differ too: ${a[-1]} gives z in zsh but bash 3.2 (macOS /bin/bash) fails with bash: a: bad array subscript. Fix: iterate with for x in "${a[@]}", run bash scripts with #!/usr/bin/env bash, or use setopt ksh_arrays in zsh code that must be 0-based. zsh 5.9 vs GNU bash 3.2.57 (macOS).