do not iterate over ls output where possible

* where possible: do not iterate over ls output
* protection on 'name with dashes becoming options'

Powered by http://www.shellcheck.net/