Article 55F3S select case from a list won't work

select case from a list won't work

by
Basher52
from LinuxQuestions.org on (#55F3S)
I got a problem that I just can't get to work.
Using Arch Linux the latest.

I create a list and that list is later used in a select/case and the only item working is the 11th as I manually add that to the previously created list.

Code:#!/bin/bash

unset options
while IFS= read -r -d $'\n' f; do
options[i++]=$(basename "$f" )
done < <(find /usr/share/kbd/keymaps/i386/* -maxdepth 1 -type d -printf "%f\n" )

IFS=$'\n'
sorted=( $(printf "%s\n" ${options[@]} | sort ))
unset IFS
exit="Don't set this... "
select opt in "${sorted[@]}" "$exit"; do
echo ">"$opt"<"
case "$opt" in
1) echo "aa" ; break ;;
2) break ;;
3) break ;;
4) break ;;
5) break ;;
6) break ;;
7) break ;;
8) break ;;
9) break ;;
"$exit") echo "e*"$opt"*" ; break ;;
*) echo "u*"$opt"*"
esac
doneThis will only result in 1 thru 10 to be captured under *) but the exit this works.
I've tried to instead of number use the values itself but the same thing happens.

Here's a log of the output

Code:[basher52@archlinux][~/temp]
$./keyb
1) azerty 3) carpalx 5) dvorak 7) include 9) qwerty 11) Don't set this...
2) bepo 4) colemak 6) fgGIod 8) olpc 10) qwertz
#? 1
>azerty<
u*azerty*
#? 2
>bepo<
u*bepo*
#? 3
>carpalx<
u*carpalx*
#? 7
>include<
u*include*
#? 9
>qwerty<
u*qwerty*
#? 11
>Don't set this... <
e*Don't set this... *
[basher52@archlinux][~/temp]
$The only one working is 11 and that one I added manually to the list in the select statement.

What is wrong with this?
This mostly works in my script as the capture only goes thru *) but in a few places I need to run other parts depending on the result.latest?d=yIl2AUoC8zA latest?i=r2443qTW3Wk:rzPgcr1hHgA:F7zBnMy latest?i=r2443qTW3Wk:rzPgcr1hHgA:V_sGLiP latest?d=qj6IDK7rITs latest?i=r2443qTW3Wk:rzPgcr1hHgA:gIN9vFwr2443qTW3Wk
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments