Use a chroot() function

Fixes a warning:
-bash: local: can only be used in a function

A local variable can only be used inside a function.
The function is also unset after use.
Merge pull request #90 from LudovicRousseau/master

Fixes a warning: -bash: local: can only be used in a function