1010
1111def run_cmd (command , verbose = False , error_print = None , cwd = None ):
1212 try :
13- if sys .stdin .isatty () and hasattr (pexpect , "spawn" ) and platform .system () != "Windows" :
13+ if (
14+ sys .stdin .isatty ()
15+ and hasattr (pexpect , "spawn" )
16+ and platform .system () != "Windows"
17+ ):
1418 return run_cmd_pexpect (command , verbose , cwd )
1519
1620 return run_cmd_subprocess (command , verbose , cwd )
@@ -47,11 +51,8 @@ def run_cmd_subprocess(command, verbose=False, cwd=None, encoding=sys.stdout.enc
4751 shell = os .environ .get ("SHELL" , "/bin/sh" )
4852 parent_process = None
4953
50- # Determine the appropriate shell
5154 if platform .system () == "Windows" :
5255 parent_process = get_windows_parent_process_name ()
53- if parent_process == "powershell.exe" :
54- command = f"powershell -Command { command } "
5556
5657 if verbose :
5758 print ("Running command:" , command )
@@ -73,6 +74,7 @@ def run_cmd_subprocess(command, verbose=False, cwd=None, encoding=sys.stdout.enc
7374 )
7475
7576 output = []
77+ assert process .stdout is not None
7678 while True :
7779 chunk = process .stdout .read (1 )
7880 if not chunk :
@@ -113,7 +115,9 @@ def output_callback(b):
113115 # Use the shell from SHELL environment variable
114116 if verbose :
115117 print ("Running pexpect.spawn with shell:" , shell )
116- child = pexpect .spawn (shell , args = ["-i" , "-c" , command ], encoding = "utf-8" , cwd = cwd )
118+ child = pexpect .spawn (
119+ shell , args = ["-i" , "-c" , command ], encoding = "utf-8" , cwd = cwd
120+ )
117121 else :
118122 # Fall back to spawning the command directly
119123 if verbose :
0 commit comments