Bug 957721 - Transform mach into a shell script that reexecutes itself with python. r=mshal
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 21 May 2014 11:27:30 +0900
changeset 184048 29a86e1eb5d2328d97fed43808a207a68d8e1b81
parent 184047 8eaecba43dc1c67454049fa191ae3dfa780ae238
child 184049 e5977dabe9411263d8ba9257f4425f6a51dc4151
push id43742
push usermh@glandium.org
push dateWed, 21 May 2014 02:29:17 +0000
treeherdermozilla-inbound@656d74108b62 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs957721
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 957721 - Transform mach into a shell script that reexecutes itself with python. r=mshal
mach
--- a/mach
+++ b/mach
@@ -1,13 +1,19 @@
-#!/usr/bin/env python
+#!/bin/sh
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+# The beginning of this script is both valid shell and valid python,
+# such that the script starts with the shell and is reexecuted with
+# the right python.
+'''which' python2.7 > /dev/null && exec python2.7 "$0" "$@" || exec python "$0" "$@"
+'''
+
 from __future__ import print_function, unicode_literals
 
 import os
 import sys
 
 def ancestors(path):
     while path:
         yield path