esh: add $# and fix syntax support

This commit is contained in:
K. Lange 2018-12-26 20:05:22 +09:00
parent 461a71aefa
commit ae55558935
3 changed files with 8 additions and 0 deletions

View File

@ -960,6 +960,8 @@ static int variable_char(uint8_t c) {
if (c >= '0' && c <= '9') return 1;
if (c == '_') return 1;
if (c == '?') return 1;
if (c == '$') return 1;
if (c == '#') return 1;
return 0;
}

View File

@ -727,6 +727,7 @@ int variable_char(uint8_t c) {
if (c == '_') return 1;
if (c == '?') return 1;
if (c == '$') return 1;
if (c == '#') return 1;
return 0;
}
@ -958,6 +959,9 @@ int shell_exec(char * buffer, size_t size, FILE * file, char ** out_buffer) {
} else if (!strcmp(var, "$")) {
sprintf(tmp,"%d",getpid());
c = tmp;
} else if (!strcmp(var, "#")) {
sprintf(tmp,"%d",shell_argc ? shell_argc-1 : 0);
c = tmp;
} else if (is_number(var)) {
int a = atoi(var);
if (a >= 0 && a < shell_argc) {

View File

@ -317,6 +317,8 @@ static int variable_char(uint8_t c) {
if (c >= '0' && c <= '9') return 1;
if (c == '_') return 1;
if (c == '?') return 1;
if (c == '$') return 1;
if (c == '#') return 1;
return 0;
}