summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAnish Athalye <me@anishathalye.com>2017-04-18 22:18:58 -0400
committerAnish Athalye <me@anishathalye.com>2017-04-19 08:40:15 -0400
commit53eb3851d1115bc825bdf1c4d6f9407e8ff414d4 (patch)
tree64b965f3c7daa21c2df5f4e6b414ae5a35388a2c /bin
parent32aa4759038dde21cc3b10960c99f0290fe11c5d (diff)
Make launcher find python binary
Diffstat (limited to 'bin')
-rwxr-xr-xbin/dotbot18
1 files changed, 17 insertions, 1 deletions
diff --git a/bin/dotbot b/bin/dotbot
index e9b432b..78a0725 100755
--- a/bin/dotbot
+++ b/bin/dotbot
@@ -1,4 +1,20 @@
-#!/usr/bin/env python
+#!/usr/bin/env sh
+
+# This is a valid shell script and also a valid Python script. When this file
+# is executed as a shell script, it finds a python binary and executes this
+# file as a Python script, passing along all of the command line arguments.
+# When this file is executed as a Python script, it loads and runs Dotbot. This
+# is useful because we don't know the name of the python binary.
+
+''':' # begin python string; this line is interpreted by the shell as `:`
+which python3 >/dev/null 2>&1 && exec python3 "$0" "$@"
+which python >/dev/null 2>&1 && exec python "$0" "$@"
+which python2 >/dev/null 2>&1 && exec python2 "$0" "$@"
+>&2 echo "error: cannot find python"
+return 1
+'''
+
+# python code
import sys, os