Convert absolute paths used in ci:validate
task to Windows format
#796
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Task task runner tool uses an integrated Bash shell interpreter to allow the use of standard POSIX/Bash syntax and built-in utilities while providing cross-platform support for users who have made the poor choice of the non-standard Windows cmd or PowerShell shells.
While this is a nice feature of Task, distinguishing it from other alternatives, it is still often necessary to use non-built-in utilities. So use of a Bash shell is a requirement to run our tasks even the developers using Windows.
Although high quality Bash shells for Windows such as the Git Bash included as part of the Git for Windows installation generally provide a seamless experience, there is the occasional "gotcha".
Relative paths work the same for POSIX and Windows, but absolute POSIX format paths may not. These paths are handled as expected by Task's integrated shell interpreter and by Bash, but when these paths are used outside that context they may no longer be correct.
For example:
The first three commands work as expected, but the
cd
command fails:The POSIX format
/tmp
is actually set to the system temporary directory:But if treated as a Windows format path, this would be the
tmp
subfolder of the root of the current drive (e.g.,C:\tmp
). Even though the command was run from Git Bash, which provides acd
that handles this absolute path perfectly, when run from Task the Windows nativecd
is used instead.This resulted in the
ci:validate
validation task, which downloads the JSON schema to the temporary folder, to fail when ran on Windows.The solution is to convert the absolute paths to Windows format (which is handled fine by both the integrated, Bash, and external applications) when the task is ran on a Windows machine. The cygpath utility provides this capability: