When I do,
$ exec 6<&0 0</tmp/lines.txt
bash exits. Why?
Thanks,
Eric J.
That makes bash read commands from /tmp/lines.txt
redirecting its input in the process. There would no longer be any input to process after all those commands in the file so the shell just exits after it, just like executing a shell script.
If you want to not let bash exit after the commands in /tmp/lines.txt were processed, make sure that you could put back its input like:
exec 6<&0 < <(cat /tmp/lines.txt; echo; echo "exec <&6";)
Which send both inputs of /tmp/lines.txt
as commands and also exec <&6
that would put back input from &6
encapsulated by process substition.
And a cleaner approach:
exec 6<&0 < <(cat /tmp/lines.txt; echo; echo "exec <&- <&6 6<&-";)
Or simply:
exec 6<&0 < <(cat /tmp/lines.txt; echo; echo "exec <&6-)