Simplify cwd slice and handle dirs with whitespace

- handle correctly dirs with whitespace
- don't use shell arrays
- take in account dir_limit input parameter

Fix #6