We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 18d27b2 commit 47980dbCopy full SHA for 47980db
x.py
@@ -1,4 +1,18 @@
1
-#!/usr/bin/env python
+# The beginning of this script is both valid shell and valid python, such that
2
+# the script starts with the shell and is reexecuted with the right python.
3
+# This works because shells only execute a line at a time.
4
+# Thanks to `./mach` from servo for the idea!
5
+''':' && {
6
+exists() { command -v "$1" >/dev/null 2>&1; }
7
+if exists python3; then
8
+ exec python3 "$0" "$@"
9
+elif exists python; then
10
+ exec python "$0" "$@"
11
+else
12
+ exec python2 "$0" "$@"
13
+fi
14
+}
15
+'''
16
17
# This file is only a "symlink" to bootstrap.py, all logic should go there.
18
0 commit comments