Last active
August 29, 2015 14:20
-
-
Save NiklasRosenstein/4cb620d1e47757cb347a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
import os | |
import pipes | |
import sys | |
import subprocess | |
# Replace this with "java.exe" or "javac.exe" to fixate this | |
# script on a certain Java executable file. | |
BINNAME = os.path.basename(sys.argv[0]) + '.exe' | |
def call(*args, **kwargs): | |
kwargs.setdefault('stdout', subprocess.PIPE) | |
kwargs.setdefault('stderr', subprocess.STDOUT) | |
p = subprocess.Popen(*args, **kwargs) | |
return p.communicate()[0] | |
def main(): | |
name = os.path.basename(sys.argv[0]) | |
binpath = os.path.join(os.getenv('JAVA_HOME'), 'bin', name) | |
args = [binpath] | |
for arg in sys.argv[1:]: | |
# Convert Cygwin paths to Windows paths. | |
if arg.startswith('/cygdrive/'): | |
arg = call(['cygpath', '-m', arg]).strip() | |
args.append(arg) | |
subprocess.call(args) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment