summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2017-08-10 13:51:41 +0200
committerJames M Snell <jasnell@gmail.com>2017-08-23 16:31:08 -0700
commitc6da5c8cdfae9e80d63f090c4289fd146c3175df (patch)
tree8b4cff42fdfb870de871ad05e8d554a7b24e9643 /configure
parent772145674cc5ae744128ca562a902ed86d3c3d0c (diff)
downloadandroid-node-v8-c6da5c8cdfae9e80d63f090c4289fd146c3175df.tar.gz
android-node-v8-c6da5c8cdfae9e80d63f090c4289fd146c3175df.tar.bz2
android-node-v8-c6da5c8cdfae9e80d63f090c4289fd146c3175df.zip
build: better support for python3 systems
Improve support for systems where `python` is actually `python3`. Not all systems have a `python2` binary, so simply updating the shebang won't work. What we can do is apply some cleverness: start life as a shell script, locate the python binary, then re-execute the script but this time as python code. Special care is taken to ensure that spaces in arguments are passed on verbatim. PR-URL: https://github.com/nodejs/node/pull/14737 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure13
1 files changed, 12 insertions, 1 deletions
diff --git a/configure b/configure
index 44ec5d2c47..994701502a 100755
--- a/configure
+++ b/configure
@@ -1,4 +1,15 @@
-#!/usr/bin/env python
+#!/bin/sh
+
+# Locate python2 interpreter and re-execute the script. Note that the
+# mix of single and double quotes is intentional, as is the fact that
+# the ] goes on a new line.
+_=[ 'exec' '/bin/sh' '-c' '''
+which python2.7 >/dev/null && exec python2.7 "$0" "$@"
+which python2 >/dev/null && exec python2 "$0" "$@"
+exec python "$0" "$@"
+''' "$0" "$@"
+]
+del _
import sys
if sys.version_info[0] != 2 or sys.version_info[1] not in (6, 7):