diff options
| author | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2008-01-17 23:58:15 +0000 |
|---|---|---|
| committer | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2008-01-17 23:58:15 +0000 |
| commit | d604bedd645c4eac1766ac6f0deba3e55078219b (patch) | |
| tree | 77a73e0cb6e70fbee5804a9e36f8050647b5ab93 /lib/base/console.cpp | |
| parent | e5107b2bd4b6167a39e4574769a0d992082296d5 (diff) | |
| download | enigma2-d604bedd645c4eac1766ac6f0deba3e55078219b.tar.gz enigma2-d604bedd645c4eac1766ac6f0deba3e55078219b.zip | |
fix cmdline parser
Diffstat (limited to 'lib/base/console.cpp')
| -rw-r--r-- | lib/base/console.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/base/console.cpp b/lib/base/console.cpp index c310bc9b..3ed0f102 100644 --- a/lib/base/console.cpp +++ b/lib/base/console.cpp @@ -109,41 +109,48 @@ int eConsoleAppContainer::execute( const char *cmd ) return -2; tmp = strchr(path, ' '); - if (!tmp) - return -3; - - *tmp = 0; - cmds = tmp+1; + if (tmp) { + *tmp = 0; + cmds = tmp+1; + while(*cmds && *cmds == ' ') + ++cmds; + } + else + cmds = path+slen; memset(argv, 0, sizeof(argv)); argv[cnt++] = path; - if (slen) { - char *argb=NULL; - char *it = find_bracket(*cmds); + if (*cmds) { + char *argb=NULL, *it=NULL; while ( (tmp = strchr(cmds, ' ')) ) { + if (!it && *cmds && (it = find_bracket(*cmds)) ) + *cmds = 'X'; // replace open braket... if (!argb) // not arg begin argb = cmds; if (it && *(tmp-1) == it[1]) { + *argb = it[0]; // set old char for open braket it = 0; } if (!it) { // end of arg + *tmp = 0; argv[cnt++] = argb; argb=0; // reset arg begin - it = find_bracket(*(tmp+1)); - *tmp = 0; } cmds = tmp+1; + while (*cmds && *cmds == ' ') + ++cmds; } argv[cnt++] = argb ? argb : cmds; + if (it) + *argv[cnt-1] = it[0]; // set old char for open braket } - // get one read ,one write and the err pipe to the prog.. - // int tmp=0; // while(argv[tmp]) // eDebug("%d is %s", tmp, argv[tmp++]); + // get one read ,one write and the err pipe to the prog.. pid = bidirpipe(fd, argv[0], argv); if ( pid == -1 ) |
