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