Fix compatibility with non Bash shells
Make some variables local
Add `eval' option for single line evaluation