esh: Support for $$

This commit is contained in:
K. Lange 2018-10-17 15:40:11 +09:00
parent c76722a4c4
commit 90b102754f

View File

@ -635,6 +635,7 @@ 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;
return 0;
}
@ -811,6 +812,9 @@ int shell_exec(char * buffer, size_t size, FILE * file, char ** out_buffer) {
if (!strcmp(var, "?")) {
sprintf(tmp,"%d",last_ret);
c = tmp;
} else if (!strcmp(var, "$")) {
sprintf(tmp,"%d",getpid());
c = tmp;
} else if (is_number(var)) {
int a = atoi(var);
if (a >= 0 && a < shell_argc) {