summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libmisc')
-rw-r--r--cpukit/libmisc/shell/shell_makeargs.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/cpukit/libmisc/shell/shell_makeargs.c b/cpukit/libmisc/shell/shell_makeargs.c
index 77d937e101..4901b54bd7 100644
--- a/cpukit/libmisc/shell/shell_makeargs.c
+++ b/cpukit/libmisc/shell/shell_makeargs.c
@@ -25,22 +25,38 @@ int rtems_shell_make_args(
)
{
int argc;
- char *command;
+ char *ch;
int status = 0;
-
+
argc = 0;
- command = commandLine;
+ ch = commandLine;
+
+ while ( *ch ) {
+
+ while ( isspace(*ch) ) ch++;
- while ( 1 ) {
- command = strtok( command, " \t\r\n" );
- if ( command == NULL )
+ if ( *ch == '\0' )
break;
- argv_p[ argc++ ] = command;
- command = '\0';
- if ( argc == (max_args-1) ) {
- status = -1;
+
+ if ( *ch == '"' ) {
+ argv_p[ argc++ ] = ++ch;
+ while ( ( *ch == '\0' ) && ( *ch != '"' ) ) ch++;
+ } else {
+ argv_p[ argc++ ] = ch;
+ while ( ( *ch == '\0' ) && ( !isspace(*ch) ) ) ch++;
+ }
+
+ if ( *ch == '\0' )
break;
+
+ *ch++ = '\0';
+
+ if ( argc == (max_args-1) ) {
+ status = -1;
+ break;
}
+
+
}
argv_p[ argc ] = NULL;
*argc_p = argc;