From d63a2c786bac552d6f9d4fe122047a603be056f6 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Mon, 9 May 2022 12:46:19 +0300 Subject: [PATCH] gst-env: spawn a shell to execute commands on windows On windows, if you are not using built-in commands you need to pass the full path of your executable into the subprocess.call/ Popen syscall. ex `c:/foo/bar/baz.exe`. This get's long and is not ergonomic when you want to run trivial task like: `gst-env.py ninja` or `gst-inspect0.0` or `gst-validate-launcher` Instead, on windows, always launch a shell to be able to resolve the executable from the PATH. Part-of: --- gst-env.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/gst-env.py b/gst-env.py index d4a0ef6885..51fb913218 100755 --- a/gst-env.py +++ b/gst-env.py @@ -547,18 +547,26 @@ if __name__ == "__main__": gst_version += '-' + os.path.basename(options.wine) env = get_subprocess_env(options, gst_version) - if not args: - if os.name == 'nt': - shell = get_windows_shell() - if shell == 'powershell.exe': - args = ['powershell.exe'] - args += ['-NoLogo', '-NoExit'] + if os.name == 'nt': + shell = get_windows_shell() + if shell == 'powershell.exe': + new_args = ['powershell.exe'] + new_args += ['-NoLogo'] + if not args: prompt = 'function global:prompt { "[gst-' + gst_version + '"+"] PS " + $PWD + "> "}' - args += ['-Command', prompt] + new_args += ['-NoExit', '-Command', prompt] else: - args = [os.environ.get("COMSPEC", r"C:\WINDOWS\system32\cmd.exe")] - args += ['/k', 'prompt [gst-{}] $P$G'.format(gst_version)] + new_args += ['-NonInteractive', '-Command'] + args + args = new_args else: + new_args = [os.environ.get("COMSPEC", r"C:\WINDOWS\system32\cmd.exe")] + if not args: + new_args += ['/k', 'prompt [gst-{}] $P$G'.format(gst_version)] + else: + new_args += ['/c', 'start', '/b', '/wait'] + args + args = new_args + if not args: + if os.name != 'nt': args = [os.environ.get("SHELL", os.path.realpath("/bin/sh"))] if args[0].endswith('bash') and not str_to_bool(os.environ.get("GST_BUILD_DISABLE_PS1_OVERRIDE", r"FALSE")): # Let the GC remove the tmp file