on Bash

working with file descriptors
for i in "${descriptors[@]}"; do exec {i}<&-; done
for i in "${!descriptors[@]}"
do exec {descriptors["$i"]}<&-; done
close file descriptors
exec {descriptors["$index"]}<"$filename"
open file descriptors into empty array
test -t
tests if it's a terminal, don't confuse
[[ -v "descriptors['$index']" ]] &&
while read -u ${descriptors["$index"]} -r
do echo "$REPLY"
done; >&2 echo We\'re at EOF
(better make sure the element exists)
read from file descriptor
default variable is REPLY
read non-zero when EOF mostly