@@ -255,13 +255,63 @@ async fn main() -> ExitCode {
255255 for command_args in alias_commands {
256256 println ! ( "Executing: {}" , command_args. join( " " ) ) ;
257257
258- let mut gg_args =
259- vec ! [ env :: current_exe ( ) . unwrap ( ) . to_string_lossy ( ) . to_string ( ) ] ;
260- gg_args . extend ( command_args . iter ( ) . map ( |s| s . to_string ( ) ) ) ;
258+ if command_args . is_empty ( ) {
259+ continue ;
260+ }
261261
262- let status = std:: process:: Command :: new ( & gg_args[ 0 ] )
263- . args ( & gg_args[ 1 ..] )
264- . status ( ) ;
262+ let execute_as_gg_command = |args : & [ String ] | {
263+ let mut gg_args = vec ! [ env:: args( ) . next( ) . unwrap_or_else( || {
264+ env:: current_exe( ) . unwrap( ) . to_string_lossy( ) . to_string( )
265+ } ) ] ;
266+ gg_args. extend ( args. iter ( ) . map ( |s| s. to_string ( ) ) ) ;
267+ std:: process:: Command :: new ( & gg_args[ 0 ] )
268+ . args ( & gg_args[ 1 ..] )
269+ . status ( )
270+ } ;
271+
272+ let status = if command_args. len ( ) == 1 {
273+ if let Some ( nested_alias_commands) =
274+ config. resolve_alias_with_and ( & command_args[ 0 ] )
275+ {
276+ let mut all_success = true ;
277+ for nested_command_args in nested_alias_commands {
278+ if nested_command_args. is_empty ( ) {
279+ continue ;
280+ }
281+ let nested_status =
282+ std:: process:: Command :: new ( & nested_command_args[ 0 ] )
283+ . args ( & nested_command_args[ 1 ..] )
284+ . status ( ) ;
285+ match nested_status {
286+ Ok ( exit_status) => {
287+ if !exit_status. success ( ) {
288+ all_success = false ;
289+ break ;
290+ }
291+ }
292+ Err ( _) => {
293+ all_success = false ;
294+ break ;
295+ }
296+ }
297+ }
298+ if all_success {
299+ std:: process:: Command :: new ( "true" ) . status ( )
300+ } else {
301+ std:: process:: Command :: new ( "false" ) . status ( )
302+ }
303+ } else if let Some ( nested_alias_args) =
304+ config. resolve_alias ( & command_args[ 0 ] )
305+ {
306+ execute_as_gg_command ( & nested_alias_args)
307+ } else {
308+ execute_as_gg_command ( & command_args)
309+ }
310+ } else {
311+ std:: process:: Command :: new ( & command_args[ 0 ] )
312+ . args ( & command_args[ 1 ..] )
313+ . status ( )
314+ } ;
265315
266316 match status {
267317 Ok ( exit_status) => {
0 commit comments