Not sure if I should put this on stackoverflow or unix.stackexchange but I found some similar questions here, so here it goes.
I\'m trying to create a script to be c
There are a couple of things about read
that are relevant here:
Since you're reading one character, it implies that entering Enter would result into an empty variable.
Moreover, by default rules for word splitting, entering Space would also result into an empty variable. The good news is that you could handle this part by setting IFS
.
Change your read
statement to:
IFS= read -s -n 1 SELECT
and expect a null string instead of $'\x0a'
when entering Enter.