Added new opcode OP_ENV to provide an env() function to get environment variables from your OS.
This commit is contained in:
parent
f3b979c07f
commit
4345fc6f0c
6 changed files with 47 additions and 3 deletions
|
|
@ -663,6 +663,14 @@ static int emit_primary(Bytecode *bc, const char *src, size_t len, size_t *pos)
|
|||
free(name);
|
||||
return 1;
|
||||
}
|
||||
if (strcmp(name, "env") == 0) {
|
||||
(*pos)++; /* '(' */
|
||||
if (!emit_expression(bc, src, len, pos)) { parser_fail(*pos, "env expects 1 argument"); free(name); return 0; }
|
||||
if (!consume_char(src, len, pos, ')')) { parser_fail(*pos, "Expected ')' after env arg"); free(name); return 0; }
|
||||
bytecode_add_instruction(bc, OP_ENV, 0);
|
||||
free(name);
|
||||
return 1;
|
||||
}
|
||||
/* string ops */
|
||||
if (strcmp(name, "split") == 0) {
|
||||
(*pos)++; /* '(' */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue