OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 ## This file is designed to be sourced from a bash script whose name takes the |
| 7 ## form 'git-sub-command'. This script will then instead invoke |
| 8 ## '[depot_tools]/gitscripts/git_sub_command.py' correctly under mingw as well |
| 9 ## as posix-ey systems, passing along all other command line flags. |
| 10 |
| 11 ## Example: |
| 12 ## echo ". python_git_runner.sh" > git-foo-command |
| 13 ## ./git-foo-command #=> runs `python gitscripts/git_foo_command.py` |
| 14 |
| 15 ## Constants |
| 16 PYTHONDONTWRITEBYTECODE=1 |
| 17 SUBDIR=gitscripts |
| 18 BASE="$(basename "$0")" |
| 19 |
| 20 ## "Input parameters". |
| 21 # If set before the script is sourced, then we'll use the pre-set values. |
| 22 # SCRIPT defaults to the basename of $0, with dashes replaced with underscores |
| 23 SCRIPT="${SCRIPT-${BASE//-/_}.py}" |
| 24 |
| 25 OUTPUT="$(uname | grep 'MINGW')" |
| 26 MINGW=$? |
| 27 |
| 28 if [ $MINGW = 0 ]; then |
| 29 base_dir="${0%\\*}" |
| 30 else |
| 31 base_dir=$(dirname "$0") |
| 32 fi |
| 33 |
| 34 if [ -e "$base_dir/python.bat" -a $MINGW = 0 ]; then |
| 35 cmd.exe //c "$base_dir\\python.bat" "$base_dir\\$SUBDIR\\$SCRIPT" "$@" |
| 36 else |
| 37 exec "$base_dir/$SUBDIR/$SCRIPT" "$@" |
| 38 fi |
OLD | NEW |