Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(585)

Side by Side Diff: tools/cr/cr-bash-helpers.sh

Issue 144243004: Fix cr-bash-helpers for Mac w/ Homebrew, which doesn't have realpath. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix formatting nit Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # Source this file into your shell to gain the cr function and tab completion 7 # Source this file into your shell to gain the cr function and tab completion
8 # for it 8 # for it
9 9
10 # Make sure we're being sourced (possibly by another script). Check for bash 10 # Make sure we're being sourced (possibly by another script). Check for bash
11 # since zsh sets $0 when sourcing. 11 # since zsh sets $0 when sourcing.
12 if [[ -n "$BASH_VERSION" && "${BASH_SOURCE:-$0}" == "$0" ]]; then 12 if [[ -n "$BASH_VERSION" && "${BASH_SOURCE:-$0}" == "$0" ]]; then
13 echo "ERROR: cr-bash-helpers.sh must be sourced." 13 echo "ERROR: cr-bash-helpers.sh must be sourced."
14 exit 1 14 exit 1
15 fi 15 fi
16 16
17 READLINK_e="readlink -e"
18 if [[ -x `which greadlink` ]]; then
19 READLINK_e="greadlink -e"
20 fi
17 21
18 cr_base_dir=$(dirname $(realpath "${BASH_SOURCE:-$0}")) 22 cr_base_dir=$(dirname $($READLINK_e "${BASH_SOURCE:-$0}"))
19 cr_main="${cr_base_dir}/main.py" 23 cr_main="${cr_base_dir}/main.py"
20 cr_exec=("PYTHONDONTWRITEBYTECODE=1" "python" "${cr_main}") 24 cr_exec=("PYTHONDONTWRITEBYTECODE=1" "python" "${cr_main}")
21 25
22 # The main entry point to the cr tool. 26 # The main entry point to the cr tool.
23 # Invokes the python script with pyc files turned off. 27 # Invokes the python script with pyc files turned off.
24 function cr() { 28 function cr() {
25 env ${cr_exec[@]} "$@" 29 env ${cr_exec[@]} "$@"
26 } 30 }
27 31
28 # Attempts to cd to the root/src of the current client. 32 # Attempts to cd to the root/src of the current client.
(...skipping 12 matching lines...) Expand all
41 local cur="${COMP_WORDS[COMP_CWORD]}" 45 local cur="${COMP_WORDS[COMP_CWORD]}"
42 local main="python -B "${cr_main}")" 46 local main="python -B "${cr_main}")"
43 local completions="$(env COMP_CWORD=${COMP_CWORD} \ 47 local completions="$(env COMP_CWORD=${COMP_CWORD} \
44 COMP_WORD=${cur} \ 48 COMP_WORD=${cur} \
45 ${cr_exec[@]})" 49 ${cr_exec[@]})"
46 COMPREPLY=( $(compgen -W "${completions}" -- ${cur}) ) 50 COMPREPLY=( $(compgen -W "${completions}" -- ${cur}) )
47 } 51 }
48 52
49 # Setup the bash auto complete 53 # Setup the bash auto complete
50 complete -F _cr_complete cr 54 complete -F _cr_complete cr
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698