Shave off whitespace at the end of a command (they would otherwise cause problems with filenames having 'invisible' trailing spaces).
This commit is contained in:
parent
f4f812d81a
commit
cd6ab0ec47
1 changed files with 13 additions and 2 deletions
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: shell.c,v 1.9 2008/02/28 23:29:07 adamdunkels Exp $
|
* $Id: shell.c,v 1.10 2008/07/03 21:15:12 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,22 +215,32 @@ start_command(char *commandline, struct shell_command *child)
|
||||||
int command_len;
|
int command_len;
|
||||||
struct shell_command *c;
|
struct shell_command *c;
|
||||||
|
|
||||||
|
/* Shave off any leading spaces. */
|
||||||
while(*commandline == ' ') {
|
while(*commandline == ' ') {
|
||||||
commandline++;
|
commandline++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Find the next command in a pipeline and start it. */
|
||||||
next = find_pipe(commandline);
|
next = find_pipe(commandline);
|
||||||
if(next != NULL) {
|
if(next != NULL) {
|
||||||
*next = 0;
|
*next = 0;
|
||||||
child = start_command(next + 1, child);
|
child = start_command(next + 1, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Separate the command arguments, and remove braces. */
|
||||||
replace_braces(commandline);
|
replace_braces(commandline);
|
||||||
args = strchr(commandline, ' ');
|
args = strchr(commandline, ' ');
|
||||||
if(args != NULL) {
|
if(args != NULL) {
|
||||||
args++;
|
args++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Shave off any trailing spaces. */
|
||||||
|
command_len = (int)strlen(commandline);
|
||||||
|
while(command_len > 0 && commandline[command_len - 1] == ' ') {
|
||||||
|
commandline[command_len - 1] = 0;
|
||||||
|
command_len--;
|
||||||
|
}
|
||||||
|
|
||||||
if(args == NULL) {
|
if(args == NULL) {
|
||||||
command_len = (int)strlen(commandline);
|
command_len = (int)strlen(commandline);
|
||||||
args = &commandline[command_len];
|
args = &commandline[command_len];
|
||||||
|
@ -509,6 +519,7 @@ shell_strtolong(const char *str, const char **retstr)
|
||||||
unsigned long
|
unsigned long
|
||||||
shell_time(void)
|
shell_time(void)
|
||||||
{
|
{
|
||||||
|
/* XXX todo: fix process to avoid wrap-around */
|
||||||
return clock_time() / CLOCK_SECOND + time_offset;
|
return clock_time() / CLOCK_SECOND + time_offset;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue