e___e
e___e

Reputation: 161

Bash : how to allow arrow keys in readarray

I'm trying to allow arrow keys in bash user input readarray. I know that you can allow them in read using -e but do you have any ideas for readarray ?

Thank you for your help.

Upvotes: 0

Views: 67

Answers (1)

chepner
chepner

Reputation: 531125

readarray isn't intended for interactive use, so it does not support using the Readline library for editing its input. Instead, you just need to use read in a loop.

declare -a arr
while read -re; do
    arr+=( "$REPLY" )
done

Upvotes: 2

Related Questions