dylanaraps / neofetch

🖼️ A command-line system information tool written in bash 3.2+
MIT License
21.93k stars 1.76k forks source link

RANDOM image? #2267

Open mined opened 1 year ago

mined commented 1 year ago

I see the line

               image="${files[RANDOM % ${#files[@]}]}"

Should that be $RANDOM?

cronsorcery commented 1 year ago

Seems like bash does arithmetic expansion when indexing arrays, so no need for $. Works in zsh and probably other shells too.

$ declare -a myarr
$ myarr=(imageA imageB imageC imageD)
$ echo "${myarr[$RANDOM % ${#myarr[@]}]}"
imageA
$ echo "${myarr[RANDOM % ${#myarr[@]}]}"
imageD