Skip to content

Commit

Permalink
host: Now can pass the full command to host include arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
rampant1018 committed Mar 20, 2014
1 parent c60253e commit 28e1c47
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,22 @@ void man_command(int n, char *argv[]){
}

void host_command(int n, char *argv[]){
if(n>1){
int len=strlen(argv[1]), rnt;
if(argv[1][0]=='\''){
argv[1][len-1]='\0';
rnt=host_system(argv[1]+1);
}else
rnt=host_system(argv[1]);
fio_printf(1, "\r\nfinish with exit code %d.\r\n", rnt);
}else
fio_printf(2, "\r\nUsage: host 'command'\r\n");
int i, len = 0, rnt;
char command[128] = {0};

if(n>1){
for(i = 1; i < n; i++) {
memcpy(&command[len], argv[i], strlen(argv[i]));
len += (strlen(argv[i]) + 1);
command[len - 1] = ' ';
}
command[len - 1] = '\0';
rnt=host_system(command);
fio_printf(1, "\r\nfinish with exit code %d.\r\n", rnt);
}
else {
fio_printf(2, "\r\nUsage: host 'command'\r\n");
}
}

void help_command(int n,char *argv[]){
Expand Down

0 comments on commit 28e1c47

Please sign in to comment.