Fixes space completion in paths in the REPL like: cd C:\\Program\ Files\\
Merge pull request #9164 from dhoegh/Backport_space_in_path_completion

Backport of #8838 and #9143 squashed