It'd be nice to fix the problem for Windows users too.
True, which I believe it would it in the small snippet above. For windows only, \ is converted to /, and the windows escape char ^ is converted to \.
Why not try fixing it in RawLocalFileSystem?
I think that could work, but windows users who might be relying on "\my\hdfs\path" to work will be in for an incompatible surprise. While it might be the right long-term approach, I think presents more risk than conditionalizing the \ to / for now.
Thinking further, perhaps this is not a bug. Perhaps the user error is assuming that backslash is an escape character in paths. The escape character in URIs is %. Does this work with 'rm %2A'?
No, it doesn't work because paths are not subject to percent encoding. Path has hybrid behavior of a URI and a File. Path is really only using a URI to hold the scheme and authority. The rest of the URI is considered a literal path. Percent encoding would require many non-alphanumeric characters to be escaped, including almost all of the glob metachars.
Changing Path to require percent encoding would be extremely disruptive and incompatible.