File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -603,24 +603,25 @@ static int nsh_execute(FAR struct nsh_vtbl_s *vtbl,
603
603
{
604
604
FAR char * sh_argv [4 ];
605
605
FAR char * sh_cmd = "sh" ;
606
- int i ;
606
+ char sh_arg2 [ CONFIG_NSH_LINELEN ] ;
607
607
608
608
DEBUGASSERT (strncmp (argv [0 ], sh_cmd , 3 ) != 0 );
609
609
610
- sh_argv [0 ] = sh_cmd ;
611
- sh_argv [1 ] = "-c" ;
612
- for (i = 0 ; i < argc - 1 ; i ++ )
613
- {
614
- FAR char * p_arg = argv [i ];
615
- size_t len = strlen (p_arg );
610
+ sh_arg2 [0 ] = '\0' ;
616
611
617
- /* Restore from split args to concat args. */
612
+ for (ret = 0 ; ret < argc ; ret ++ )
613
+ {
614
+ strlcat (sh_arg2 , argv [ret ], sizeof (sh_arg2 ));
618
615
619
- DEBUGASSERT (& p_arg [len + 1 ] == argv [i + 1 ]);
620
- p_arg [len ] = ' ' ;
616
+ if (ret < argc - 1 )
617
+ {
618
+ strcat (sh_arg2 , " " );
619
+ }
621
620
}
622
621
623
- sh_argv [2 ] = argv [0 ];
622
+ sh_argv [0 ] = sh_cmd ;
623
+ sh_argv [1 ] = "-c" ;
624
+ sh_argv [2 ] = sh_arg2 ;
624
625
sh_argv [3 ] = NULL ;
625
626
626
627
/* np.np_bg still there, try use nsh_builtin or nsh_fileapp to
You can’t perform that action at this time.
0 commit comments