Fix rebar_file_utils module on Windows with MSYS #142
Closed
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.
Currently rebar_utils:sh/2 will invoke all commands through bash.exe if found. Otherwise the command will be executed directly. Despite the fact that the caller cannot know if the command is executed with Unix or Windows semantics it leads to the following problem:
The rebar_file_utils module (namely rm_rf/1, cp_r/2 and mv/2) is not working as expected on Windows when MSYS is installed. These functions call cmd.exe with some options (e.g. /c) and native path names. There are two problems with this: first any backslashes would have to be escaped (easy to fix) and options like '/c' are expanded to 'C:' by the MSYS automatic path name translation.
Therefore stop using bash on Windows to get a consistent behavior and to avoid the peculiarities of MSYS's automatic path conversion.
This will impact all calls to rebar_utils:sh/2 on Windows. I did test most of rebars commands (clean, compile, create, *-deps, generate) and the rebar_file_utils eunit test suite. But because this touches a very core part of rebar I'd love to get some testing feedback first before the pull request gets merged...