Browse Source

esh: Support for $$

K. Lange 4 years ago
parent
commit
90b102754f
1 changed files with 4 additions and 0 deletions
  1. 4 0
      apps/sh.c

+ 4 - 0
apps/sh.c

@@ -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) {