@@ -378,6 +378,10 @@ def _preprocess_command(self, command: List[str]) -> List[str]:
378378 preprocessed_command .append (token )
379379 return preprocessed_command
380380
381+ def _get_default_shell (self ) -> str :
382+ """Get the default shell from environment variables"""
383+ return os .environ .get ("SHELL" , "/bin/sh" )
384+
381385 async def execute (
382386 self ,
383387 command : List [str ],
@@ -517,14 +521,17 @@ async def execute(
517521 except IOError as e :
518522 raise ValueError (f"Failed to open output file: { e } " ) from e
519523
520- # Execute the command
524+ # Execute the command with interactive shell
525+ shell = self ._get_default_shell ()
521526 shell_cmd = self ._create_shell_command (cmd )
527+ shell_cmd = f"{ shell } -i -c { shlex .quote (shell_cmd )} "
528+
522529 process = await asyncio .create_subprocess_shell (
523530 shell_cmd ,
524531 stdin = asyncio .subprocess .PIPE if stdin else None ,
525532 stdout = stdout_handle ,
526533 stderr = asyncio .subprocess .PIPE ,
527- env = { "PATH" : os .environ . get ( "PATH" , "" )},
534+ env = os .environ , # Use all environment variables
528535 cwd = directory ,
529536 )
530537
@@ -642,12 +649,17 @@ async def _execute_pipeline(
642649 for i , cmd in enumerate (parsed_commands ):
643650 shell_cmd = self ._create_shell_command (cmd )
644651
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+
645657 process = await asyncio .create_subprocess_shell (
646658 shell_cmd ,
647659 stdin = asyncio .subprocess .PIPE if prev_stdout is not None else None ,
648660 stdout = asyncio .subprocess .PIPE ,
649661 stderr = asyncio .subprocess .PIPE ,
650- env = { "PATH" : os .environ . get ( "PATH" , "" )},
662+ env = os .environ , # Use all environment variables
651663 cwd = directory ,
652664 )
653665
0 commit comments