-
Notifications
You must be signed in to change notification settings - Fork 124
Description
Since on windows path can still have issues when invoking utils via cmd.exe It may be better if this task just use some APIs to adjust the timestamp.
cmd.exe's help says:
If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic is
used to process quote (") characters:1. If all of the following conditions are met, then quote characters on the command line are preserved: - no /S switch - exactly two quote characters - no special characters between the two quote characters, where special is one of: &<>()@^| - there are one or more whitespace characters between the two quote characters - the string between the two quote characters is the name of an executable file. 2. Otherwise, old behavior is to see if the first character is a quote character and if so, strip the leading character and remove the last quote character on the command line, preserving any text after the last quote character.
This is tricky to grok, but keep in mind that when invoking a command line on Windows, we (Foundation.NSTask / SwiftSubprocess) do manual quoting of the contents of the command line array to turn it into something that will "round trip" through CommandLineToArgvW. For example, note the difference:
C:\Users\jakepetroules>cmd /c echo "hello world"
"hello world"
C:\Users\jakepetroules>cmd /c "echo hello world"
hello world
I don't know if how cmd.exe decides to parse the remainder of its command line (as described above) is the same as CommandLineToArgvW.
It might be preferable to introduce a custom task action and update the timestamp via API rather than by invoking touch on the CLI, to ensure robustness with odd filenames. That could be a separate PR though.
Originally posted by @jakepetroules in #853 (comment)