summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMathias Preiner <mathias.preiner@gmail.com>2019-08-02 13:49:03 -0700
committerAndrew Reynolds <andrew.j.reynolds@gmail.com>2019-08-02 15:49:03 -0500
commit13f6d4b71a194f74001f7a6fbe92bbb2c5c62813 (patch)
tree7d8720e285c44aa18aa70529f95a29d10b49f173 /contrib
parentae83890dc38177f7c5c9cf07d7905ea7bf62d055 (diff)
Add better Python detection for contrib scripts. (#3150)
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/get-antlr-3.44
-rw-r--r--contrib/get-script-header.sh16
2 files changed, 16 insertions, 4 deletions
diff --git a/contrib/get-antlr-3.4 b/contrib/get-antlr-3.4
index 6bfa18c46..a3dfb410d 100755
--- a/contrib/get-antlr-3.4
+++ b/contrib/get-antlr-3.4
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
#
source "$(dirname "$0")/get-script-header.sh"
ANTLR_HOME_DIR=antlr-3.4
@@ -46,7 +46,7 @@ cd libantlr3c-3.4
# Use an absolute path for the installation directory to avoid spurious libtool
# warnings about the ANTLR library having moved
-PREFIX=$(python -c "import os; print(os.path.realpath('$(pwd)/../..'))")
+PREFIX=$($PYTHON -c "import os; print(os.path.realpath('$(pwd)/../..'))")
# Make antlr3debughandlers.c empty to avoid unreferenced symbols
rm -rf src/antlr3debughandlers.c && touch src/antlr3debughandlers.c
diff --git a/contrib/get-script-header.sh b/contrib/get-script-header.sh
index de4a93587..e5b708042 100644
--- a/contrib/get-script-header.sh
+++ b/contrib/get-script-header.sh
@@ -1,6 +1,6 @@
-#!/bin/bash
+#!/usr/bin/env bash
#
-set -e
+set -e -o pipefail
cd "$(dirname "$0")/.."
@@ -24,3 +24,15 @@ function webget {
exit 1
fi
}
+
+for cmd in python python2 python3; do
+ if [ -x "$(command -v $cmd)" ]; then
+ PYTHON="$cmd"
+ break
+ fi
+done
+
+if [ -z "$PYTHON" ]; then
+ echo "Error: Couldn't find python, python2, or python3." >&2
+ exit 1
+fi
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback