esh: add $# and fix syntax support
This commit is contained in:
parent
461a71aefa
commit
ae55558935
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user