I am trying to create a select in bash that lets you select items from a .txt file. Each item is a new line, I read the items and put them in an array using:
items=()
while read -r line; do
items+=("$line")
done <items.txt
this works fine.
After that I put them in a select using:
PS3="Choose Item > "
select item in "${items[@]}" "Cancel"; do
case ${item} in
Cancel)
echo "You chose to cancel"
break
;;
*)
echo "You chose ${item}"
break
;;
esac
done
The select displays all items line by line. This all works fine until there are more than 9 items. When there are more than 9 items it displays them really weird. It also combines item names. See picture below.
I read online it maybe has to do something with how bash reads the numbered argument. But I couldn't find any sollutions. Why do bash command line arguments after 9 require curly brackets?
Does someone know how to fix the problem of only being able to have up to 9/10 options in the bash select?