Changing lsdir to consistently return an slist

This is a backport of 2e5a9640e62405de2a9acf56cc5d032fbc4aa630a to the
3.4.x branch.