Merge pull request #159 from eurodude/patch-1

Allow for multiple entries like 1 2 3 4 5
This commit is contained in:
Alexandre Dulaunoy 2017-11-28 15:18:31 +01:00 committed by GitHub
commit 29aa5b8eaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -239,13 +239,15 @@ menu() {
}
prompt="Check an option (again to uncheck, ENTER when done): "
while menu && read -rp "$prompt" num && [[ "$num" ]]; do
while menu && read -rp "$prompt" numinput && [[ "$numinput" ]]; do
for num in $numinput; do
[[ "$num" != *[![:digit:]]* ]] && (( num > 0 && num <= ${#options[@]} )) || {
msg="Invalid option: $num"; continue
msg="Invalid option: $num"; break
}
((num--)); msg="${options[num]} was ${choices[num]:+un}checked"
[[ "${choices[num]}" ]] && choices[num]="" || choices[num]="+"
done
done
for i in ${!options[@]}; do
if [[ "${choices[i]}" ]]; then