|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
| 3 | +# Bash Unofficial strict mode (http://redsymbol.net/articles/unofficial-bash-strict-mode/) |
| 4 | +# and (https://disconnected.systems/blog/another-bash-strict-mode/) |
| 5 | +set -o nounset # Any uninitialized variable is an error |
| 6 | +set -o errexit # Exit the script on the failure of any command to execute without error |
| 7 | +set -o pipefail # Fail command pipelines on the failure of any individual step |
| 8 | +IFS=$'\n\t' #set internal field separator to avoid iteration errors |
| 9 | +# Trap all exits and output something helpful |
| 10 | +trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR |
| 11 | + |
3 | 12 | echo "Checking virtual environment" |
4 | | -if [ -z "${VIRTUAL_ENV}" ] && [ -z "${CONDA_PREFIX}" ]; then |
| 13 | +if [ "${VIRTUAL_ENV:-missing}" = "missing" ] && [ "${CONDA_PREFIX:-missing}" = "missing" ]; then |
5 | 14 | echo 'No virtual environment detected: none of $VIRTUAL_ENV or $CONDA_PREFIX is set.' |
6 | 15 | echo |
7 | 16 | echo "=== This script is going to install the project in the system python environment ===" |
|
17 | 26 |
|
18 | 27 | echo "Checking pip version" |
19 | 28 | MINIMUM_PIP_VERSION=22 |
20 | | -pipversion=( $(python -m pip --version | awk '{print $2}' | sed 's/\./ /g') ) |
| 29 | +pipversion=( $(python -m pip --version | awk '{print $2}' | sed 's/\./\n\t/g') ) |
21 | 30 | if let "${pipversion[0]}<${MINIMUM_PIP_VERSION}"; then |
22 | 31 | echo "Insufficient version of pip found. Requires at least version ${MINIMUM_PIP_VERSION}." |
23 | 32 | echo "See https://lincc-ppt.readthedocs.io/ for details." |
|
26 | 35 |
|
27 | 36 | echo "Initializing local git repository" |
28 | 37 | { |
29 | | - gitversion=( $(git version | git version | awk '{print $3}' | sed 's/\./ /g') ) |
| 38 | + gitversion=( $(git version | git version | awk '{print $3}' | sed 's/\./\n\t/g') ) |
30 | 39 | if let "${gitversion[0]}<2"; then |
31 | 40 | # manipulate directly |
32 | 41 | git init . && echo 'ref: refs/heads/main' >.git/HEAD |
|
0 commit comments