today i had a situation where i had a loop and it was creating 4 elements instead of 3. for example, this is how i was looping my array:

# INSTALL DEPENCIES
packages=("react-router-dom" "axios" "vite-plugin-mkcert -D" "bootstrap")
for package in ${packages[@]}; do
  PACKAGE="y"
  if [[ $ORVERIDE == "n" ]]; then
    read -p "Do you want to install ${package} y/n: [n] " PACKAGE
  fi
  if [[ $PACKAGE == "y" ]]; then
    npm i $package
    set -e
  fi
done

 

OUTPUT:

[0] = react-router-dom
[1] = axios
[2] = vite-plugin-mkcert
[3] = -D
[4] = bootstrap

For some readson it was creating an extra element from vite-plugin-mkcert -D

Solution:

Change From: ${packages[@]}

Change To: "${packages[@]}"

Now it works.