@@ -80,7 +80,14 @@ def env():
8080PROMPT_CWD = "\\ W"
8181
8282
83- def launch_shell (host : str , context : str , allow : list [str ], unsafe : bool ) -> int :
83+ def launch_shell (
84+ host : str ,
85+ context : str ,
86+ allow : [str ],
87+ unsafe : bool ,
88+ * ,
89+ command : tuple [str , ...] | None = None ,
90+ ) -> int :
8491 """Launch a shell with a custom prompt indicating the exporter type.
8592
8693 Args:
@@ -89,21 +96,21 @@ def launch_shell(host: str, context: str, allow: list[str], unsafe: bool) -> int
8996 allow: List of allowed drivers
9097 unsafe: Whether to allow drivers outside of the allow list
9198 """
92- cmd = [ os . environ . get ( "SHELL" , "bash" )]
93- if cmd [ 0 ]. endswith ( "bash" ):
94- cmd . append ( "--norc" )
95- cmd . append ( "--noprofile" )
96-
97- process = Popen (
98- cmd ,
99- stdin = sys . stdin ,
100- stdout = sys .stdout ,
101- stderr = sys . stderr ,
102- env = os .environ
103- | {
104- JUMPSTARTER_HOST : host ,
105- JMP_DRIVERS_ALLOW : "UNSAFE" if unsafe else "," . join ( allow ),
106- "PS1" : f" { ANSI_GRAY } { PROMPT_CWD } { ANSI_YELLOW } ⚡ { ANSI_WHITE } { context } { ANSI_YELLOW } ➤ { ANSI_RESET } " ,
107- },
108- )
99+
100+ env = os . environ | {
101+ JUMPSTARTER_HOST : host ,
102+ JMP_DRIVERS_ALLOW : "UNSAFE" if unsafe else "," . join ( allow ),
103+ "PS1" : f" { ANSI_GRAY } { PROMPT_CWD } { ANSI_YELLOW } ⚡ { ANSI_WHITE } { context } { ANSI_YELLOW } ➤ { ANSI_RESET } " ,
104+ }
105+
106+ if command :
107+ process = Popen ( command , stdin = sys . stdin , stdout = sys .stdout , stderr = sys . stderr , env = env )
108+ else :
109+ cmd = [ os .environ . get ( "SHELL" , "bash" )]
110+ if cmd [ 0 ]. endswith ( "bash" ):
111+ cmd . append ( "--norc" )
112+ cmd . append ( "--noprofile" )
113+
114+ process = Popen ( cmd , stdin = sys . stdin , stdout = sys . stdout , stderr = sys . stderr , env = env )
115+
109116 return process .wait ()
0 commit comments