diff --git a/apps/bim.c b/apps/bim.c index 8c6c791b..08cfcfbd 100644 --- a/apps/bim.c +++ b/apps/bim.c @@ -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; } diff --git a/apps/sh.c b/apps/sh.c index 6cd23e18..88babf05 100644 --- a/apps/sh.c +++ b/apps/sh.c @@ -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) { diff --git a/lib/rline_exp.c b/lib/rline_exp.c index 4f3e91ae..dcb72230 100644 --- a/lib/rline_exp.c +++ b/lib/rline_exp.c @@ -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; }