@@ -3,38 +3,38 @@ use crate::{CmdEnv, CmdResult};
33use std:: io:: { Read , Write } ;
44
55pub ( crate ) fn builtin_echo ( env : & mut CmdEnv ) -> CmdResult {
6- let args = env. args ( ) ;
7- let msg = if args. len ( ) > 1 && args[ 1 ] == "-n" {
8- args[ 2 ..] . join ( " " )
6+ let args = env. get_args ( ) ;
7+ let msg = if ! args. is_empty ( ) && args[ 0 ] == "-n" {
8+ args[ 1 ..] . join ( " " )
99 } else {
10- args[ 1 .. ] . join ( " " ) + "\n "
10+ args. join ( " " ) + "\n "
1111 } ;
1212
1313 write ! ( env. stdout( ) , "{}" , msg)
1414}
1515
1616pub ( crate ) fn builtin_error ( env : & mut CmdEnv ) -> CmdResult {
17- error ! ( "{}" , env. args ( ) [ 1 .. ] . join( " " ) ) ;
17+ error ! ( "{}" , env. get_args ( ) . join( " " ) ) ;
1818 Ok ( ( ) )
1919}
2020
2121pub ( crate ) fn builtin_warn ( env : & mut CmdEnv ) -> CmdResult {
22- warn ! ( "{}" , env. args ( ) [ 1 .. ] . join( " " ) ) ;
22+ warn ! ( "{}" , env. get_args ( ) . join( " " ) ) ;
2323 Ok ( ( ) )
2424}
2525
2626pub ( crate ) fn builtin_info ( env : & mut CmdEnv ) -> CmdResult {
27- info ! ( "{}" , env. args ( ) [ 1 .. ] . join( " " ) ) ;
27+ info ! ( "{}" , env. get_args ( ) . join( " " ) ) ;
2828 Ok ( ( ) )
2929}
3030
3131pub ( crate ) fn builtin_debug ( env : & mut CmdEnv ) -> CmdResult {
32- debug ! ( "{}" , env. args ( ) [ 1 .. ] . join( " " ) ) ;
32+ debug ! ( "{}" , env. get_args ( ) . join( " " ) ) ;
3333 Ok ( ( ) )
3434}
3535
3636pub ( crate ) fn builtin_trace ( env : & mut CmdEnv ) -> CmdResult {
37- trace ! ( "{}" , env. args ( ) [ 1 .. ] . join( " " ) ) ;
37+ trace ! ( "{}" , env. get_args ( ) . join( " " ) ) ;
3838 Ok ( ( ) )
3939}
4040
0 commit comments