fix #18670 quoteShellCommand, quoteShell, quoteShellWindows on windows (#18671)

This commit is contained in:
Timothee Cour 2021-08-12 07:50:08 -07:00 • committed by GitHub
commit 5c1304a418
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View file

@ -622,7 +622,18 @@ block: # quoteShellWindows
doAssert quoteShellWindows("aaa\"") == "aaa\\\""
doAssert quoteShellWindows("") == "\"\""
block: # quoteShellWindows
block: # quoteShellCommand
when defined(windows):
doAssert quoteShellCommand(["a b c", "d", "e"]) == """"a b c" d e"""
doAssert quoteShellCommand(["""ab"c""", r"\", "d"]) == """ab\"c \ d"""
doAssert quoteShellCommand(["""ab"c""", """ \""", "d"]) == """ab\"c " \\" d"""
doAssert quoteShellCommand(["""a\\\b""", """de fg""", "h"]) == """a\\\b "de fg" h"""
doAssert quoteShellCommand(["""a\"b""", "c", "d"]) == """a\\\"b c d"""
doAssert quoteShellCommand(["""a\\b c""", "d", "e"]) == """"a\\b c" d e"""
doAssert quoteShellCommand(["""a\\b\ c""", "d", "e"]) == """"a\\b\ c" d e"""
doAssert quoteShellCommand(["ab", ""]) == """ab """""
block: # quoteShellPosix
doAssert quoteShellPosix("aaa") == "aaa"
doAssert quoteShellPosix("aaa a") == "'aaa a'"
doAssert quoteShellPosix("") == "''"