exec independently (without arguments) does not start a new process, but can be used to manage file descriptors in the current process.
What do these lines do:
- temporarily save the current standard input (file descriptor 0) to file descriptor 3.
- change the standard input to read from
$FILE. - do the reading.
- ( 3).
IFS reset read, "\n\b" while reset IFS=$BAKIFS ( ).
:
BAKIFS=$IFS
IFS=$(echo -en "\n\b")
exec 3<&0
exec 0<"$FILE"
while read -r line ; do
processLine $line
done
exec 0<&3
IFS=$BAKIFS