1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 ## This file is designed to be sourced from a bash script whose name takes the
6 ## form 'git-sub-command'. This script will then instead invoke
7 ## '[depot_tools]/git_sub_command.py' correctly under mingw as well
8 ## as posix-ey systems, passing along all other command line flags.
11 ## echo ". python_git_runner.sh" > git-foo-command
12 ## ./git-foo-command #=> runs `python git_foo_command.py`
15 PYTHONDONTWRITEBYTECODE=1
17 ## "Input parameters".
18 # If set before the script is sourced, then we'll use the pre-set values.
20 # SCRIPT defaults to the basename of $0, with dashes replaced with underscores
22 if [[ $OSTYPE = msys ]]
24 DEPOT_TOOLS="${0%\\*}"
30 SCRIPT="${SCRIPT-${BASENAME//-/_}.py}"
32 if [[ -e "$DEPOT_TOOLS/python.bat" && $OSTYPE = msys ]]; then
33 cmd.exe //c "$DEPOT_TOOLS\\python.bat" "$DEPOT_TOOLS\\$SCRIPT" "$@"
35 exec "$DEPOT_TOOLS/$SCRIPT" "$@"