added support for '-' in filenames

This adds support for minuses in filenames.
It is a cleaned up version of  #1772