I'm not sure what you are trying to accomplish, but it smells dangerous.
In here:
Quote:
echo "ls
ls -l" | while read line;do
eval $line
done
you would call 'eval <file>' for each file on the remote system. You almost certainly don't want to do that.
If there was a file named 'rm -rf $dir' in that dir, with your loop you'd execute just that! It's not good to use eval unless you're sure that eval's argument is fixed and you know what it is.
So, to answer your question: It's not the strange behavior of eval, it's the strange construct that you cooked. Look at the contents of the directory. If you had a file named 'break' in that dir, you'd end the loop when 'eval break' gets called.