Fix python2 wrapper for msys.

The python_bin_reldir.txt path to find the python2 binary will
contain backslashes instead of forward slashes on Windows, so
this tweaks the wrapper in //python2-bin/python2 to handle that
and start working under msys.

Bug: 1168365
Change-Id: If0876054f0a73c9a53a1eb23ea03c60c1e756c29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2729410
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
diff --git a/python2-bin/python2 b/python2-bin/python2
index 8952755..a5a27f2 100755
--- a/python2-bin/python2
+++ b/python2-bin/python2
@@ -2,6 +2,13 @@
 
 DEPOT_TOOLS=$(dirname "$0")/..
 
-PYTHON_BIN_DIR="$DEPOT_TOOLS/$(cat $DEPOT_TOOLS/python_bin_reldir.txt | xargs echo)"
+if [ "$OSTYPE" = "msys" ]
+then
+  # msys is `git bash` on windows, so python_bin_reldir contains backslashes;
+  # this converts them to the forward slashes a unix environment expects.
+  PYTHON_BIN_DIR="$DEPOT_TOOLS/$(sed -e 's-\\-/-g' $DEPOT_TOOLS/python_bin_reldir.txt)"
+else
+  PYTHON_BIN_DIR="$DEPOT_TOOLS/$(cat $DEPOT_TOOLS/python_bin_reldir.txt)"
+fi
 PATH="$PYTHON_BIN_DIR":"$PATH"
 "$PYTHON_BIN_DIR/python" "$@"