From 361822cb2ddcad3813746508ef9c5b8c6e767a81 Mon Sep 17 00:00:00 2001 From: Brian White Date: Wed, 4 Apr 2018 15:21:45 -0400 Subject: [PATCH] Convert CygWin paths to Windows native for CIPD. Bug: 828981 Change-Id: Ibd4b31413bcdbbfe9bb1076334c892f1a30c768e Reviewed-on: https://chromium-review.googlesource.com/996432 Commit-Queue: Brian White Reviewed-by: Robbie Iannucci --- cipd | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cipd b/cipd index 581b4b0ba..16a5f64c2 100755 --- a/cipd +++ b/cipd @@ -6,6 +6,7 @@ set -e -o pipefail +CYGWIN=false MYPATH=$(dirname "${BASH_SOURCE[0]}") : ${CIPD_CLIENT_VER:=`cat $MYPATH/cipd_client_version`} @@ -16,7 +17,11 @@ case $UNAME in linux) PLAT=linux ;; - cygwin*|msys*|mingw*) + cygwin*) + PLAT=windows + CYGWIN=true + ;; + msys*|mingw*) PLAT=windows ;; darwin) @@ -106,4 +111,20 @@ if ! "$CLIENT" selfupdate -version "$CIPD_CLIENT_VER" ; then echo "" 1>&2 fi +# CygWin requires changing absolute paths to Windows form. Relative paths +# are typically okay as Windows generally accepts both forward and back +# slashes. This could possibly be constrained to only /tmp/ and /cygdrive/. +if $CYGWIN; then + args=("$@") + for i in `seq 2 $#`; do + arg="${@:$i:1}" + if [ "${arg:0:1}" == "/" ]; then + last=$((i-1)) + next=$((i+1)) + set -- "${@:1:$last}" `cygpath -w "$arg"` "${@:$next}" + fi + done + echo "$CLIENT" "${@}" +fi + exec "$CLIENT" "${@}"