@@ -248,7 +248,9 @@ def normalize_path(self, path):
248248
249249 This isn't explicitely necessary on Windows since around Windows 7,
250250 PowerShell has supported mixed slashes as a path separator. However,
251- we can still call this method to normalize paths for consistency.
251+ we can still call this method to normalize paths for consistency, and
252+ have better interoperability with some software such as cmake which
253+ prefer forward slashes e.g. GH issue #1321.
252254
253255 Args:
254256 path (str): Path to normalize.
@@ -261,7 +263,8 @@ def normalize_path(self, path):
261263 return path
262264
263265 if platform_ .name == "windows" :
264- normalized_path = path .replace ("/" , "\\ " )
266+ path = os .path .normpath (path )
267+ normalized_path = path .replace ("\\ " , "/" )
265268 if path != normalized_path :
266269 log ("PowerShellBase normalize_path()" )
267270 log ("Path normalized: {!r} -> {!r}" .format (path , normalized_path ))
@@ -352,6 +355,8 @@ def join(cls, command):
352355 if isinstance (command , six .string_types ):
353356 return command
354357
358+ find_unsafe = re .compile (r'[^\w@%+`:,./-]' ).search
359+
355360 replacements = [
356361 # escape ` as ``
357362 ('`' , "``" ),
@@ -360,7 +365,7 @@ def join(cls, command):
360365 ('"' , '`"' )
361366 ]
362367
363- joined = shlex_join (command , replacements = replacements )
368+ joined = shlex_join (command , unsafe_regex = find_unsafe , replacements = replacements )
364369
365370 # add call operator in case executable gets quotes applied
366371 # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7.1#call-operator-
0 commit comments