rexec: support send command with arguments

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2021-10-20 16:00:58 +08:00 committed by Xiang Xiao
parent 98dfaa3eff
commit b480d00323

View File

@ -114,8 +114,10 @@ static int do_rexec(FAR struct rexec_arg_s *arg)
int main(int argc, FAR char **argv)
{
char cmd[CONFIG_NSH_LINELEN];
struct rexec_arg_s arg;
int option;
int i;
memset(&arg, 0, sizeof(arg));
@ -159,6 +161,13 @@ int main(int argc, FAR char **argv)
usage(argv[0]);
}
arg.command = argv[optind];
cmd[0] = '\0';
for (i = optind; i < argc; i++)
{
strcat(cmd, argv[i]);
strcat(cmd, " ");
}
arg.command = cmd;
return do_rexec(&arg);
}