mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 06:12:43 +01:00
Print error message on any quoting error
This commit is contained in:
parent
c507632e50
commit
829966ee32
@ -90,6 +90,8 @@ static void print_help(const shell_command_t *command_list)
|
||||
|
||||
static void handle_input_line(shell_t *shell, char *line)
|
||||
{
|
||||
static const char *INCORRECT_QUOTING = "shell: incorrect quoting";
|
||||
|
||||
/* first we need to calculate the number of arguments */
|
||||
unsigned argc = 0;
|
||||
char *pos;
|
||||
@ -102,14 +104,22 @@ static void handle_input_line(shell_t *shell, char *line)
|
||||
do {
|
||||
++pos;
|
||||
if (!*pos) {
|
||||
puts("shell: incorrect quoting");
|
||||
puts(INCORRECT_QUOTING);
|
||||
return;
|
||||
}
|
||||
} while (*pos != '"');
|
||||
if (pos[1] > ' ') {
|
||||
puts(INCORRECT_QUOTING);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
do {
|
||||
++pos;
|
||||
if (*pos == '"') {
|
||||
puts(INCORRECT_QUOTING);
|
||||
return;
|
||||
}
|
||||
} while (*pos > ' ');
|
||||
}
|
||||
++argc;
|
||||
|
@ -28,34 +28,44 @@
|
||||
|
||||
#define SHELL_BUFSIZE (UART0_BUFSIZE)
|
||||
|
||||
void print_teststart(char *unused)
|
||||
static void print_teststart(int argc, char **argv)
|
||||
{
|
||||
(void) unused;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
printf("[TEST_START]\n");
|
||||
|
||||
}
|
||||
|
||||
void print_testend(char *unused)
|
||||
static void print_testend(int argc, char **argv)
|
||||
{
|
||||
(void) unused;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
printf("[TEST_END]\n");
|
||||
}
|
||||
|
||||
int shell_readc(void)
|
||||
static void print_echo(int argc, char **argv)
|
||||
{
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
printf("“%s” ", argv[i]);
|
||||
}
|
||||
puts("");
|
||||
}
|
||||
|
||||
static int shell_readc(void)
|
||||
{
|
||||
char c = 0;
|
||||
posix_read(uart0_handler_pid, &c, 1);
|
||||
return c;
|
||||
}
|
||||
|
||||
void shell_putchar(int c)
|
||||
static void shell_putchar(int c)
|
||||
{
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
const shell_command_t shell_commands[] = {
|
||||
static const shell_command_t shell_commands[] = {
|
||||
{ "start_test", "starts a test", print_teststart },
|
||||
{ "end_test", "ends a test", print_testend },
|
||||
{ "echo", "prints the input command", print_echo },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user