Rob Mohr | cacb877 | 2019-11-22 13:14:01 -0800 | [diff] [blame^] | 1 | # Copyright 2019 The Pigweed Authors |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 4 | # use this file except in compliance with the License. You may obtain a copy of |
| 5 | # the License at |
| 6 | # |
| 7 | # https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations under |
| 13 | # the License. |
| 14 | |
| 15 | # This script must be tested on bash, zsh, and dash. |
| 16 | |
| 17 | # Shell: bash. |
| 18 | if test -n "$BASH"; then |
| 19 | PW_SETUP_SCRIPT_PATH=$(realpath $BASH_SOURCE) |
| 20 | # Shell: zsh. |
| 21 | elif test -n "$ZSH_NAME"; then |
| 22 | PW_SETUP_SCRIPT_PATH=$(realpath ${(%):-%N}) |
| 23 | # Shell: dash. |
| 24 | elif test ${0##*/} = dash; then |
| 25 | PW_SETUP_SCRIPT_PATH=$(realpath \ |
| 26 | $(lsof -p $$ -Fn0 | tail -1 | sed 's#^[^/]*##;')) |
| 27 | # If everything else fails, try $0. It could work. |
| 28 | else |
| 29 | PW_SETUP_SCRIPT_PATH=$(realpath $0) |
| 30 | fi |
| 31 | |
| 32 | PW_ENVSETUP=$(dirname $PW_SETUP_SCRIPT_PATH) |
| 33 | export PW_ENVSETUP |
| 34 | |
| 35 | PW_ROOT=$(dirname "$PW_ENVSETUP") |
| 36 | export PW_ROOT |
| 37 | |
| 38 | . "$PW_ENVSETUP/cipd/init.sh" |
| 39 | . "$PW_ENVSETUP/virtualenv/init.sh" |