@@ -378,6 +378,10 @@ def _preprocess_command(self, command: List[str]) -> List[str]:
378
378
preprocessed_command .append (token )
379
379
return preprocessed_command
380
380
381
+ def _get_default_shell (self ) -> str :
382
+ """Get the default shell from environment variables"""
383
+ return os .environ .get ("SHELL" , "/bin/sh" )
384
+
381
385
async def execute (
382
386
self ,
383
387
command : List [str ],
@@ -517,14 +521,17 @@ async def execute(
517
521
except IOError as e :
518
522
raise ValueError (f"Failed to open output file: { e } " ) from e
519
523
520
- # Execute the command
524
+ # Execute the command with interactive shell
525
+ shell = self ._get_default_shell ()
521
526
shell_cmd = self ._create_shell_command (cmd )
527
+ shell_cmd = f"{ shell } -i -c { shlex .quote (shell_cmd )} "
528
+
522
529
process = await asyncio .create_subprocess_shell (
523
530
shell_cmd ,
524
531
stdin = asyncio .subprocess .PIPE if stdin else None ,
525
532
stdout = stdout_handle ,
526
533
stderr = asyncio .subprocess .PIPE ,
527
- env = { "PATH" : os .environ . get ( "PATH" , "" )},
534
+ env = os .environ , # Use all environment variables
528
535
cwd = directory ,
529
536
)
530
537
@@ -642,12 +649,17 @@ async def _execute_pipeline(
642
649
for i , cmd in enumerate (parsed_commands ):
643
650
shell_cmd = self ._create_shell_command (cmd )
644
651
652
+ # Get default shell for the first command and set interactive mode
653
+ if i == 0 :
654
+ shell = self ._get_default_shell ()
655
+ shell_cmd = f"{ shell } -i -c { shlex .quote (shell_cmd )} "
656
+
645
657
process = await asyncio .create_subprocess_shell (
646
658
shell_cmd ,
647
659
stdin = asyncio .subprocess .PIPE if prev_stdout is not None else None ,
648
660
stdout = asyncio .subprocess .PIPE ,
649
661
stderr = asyncio .subprocess .PIPE ,
650
- env = { "PATH" : os .environ . get ( "PATH" , "" )},
662
+ env = os .environ , # Use all environment variables
651
663
cwd = directory ,
652
664
)
653
665
0 commit comments