Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
env.c File Reference

Implements OP_ENV to read an environment variable by name. More...

Go to the source code of this file.

Functions

 if (key.type !=VAL_STRING)
 push_value (vm, make_string(val ? val :""))
 free_value (key)

Variables

case OP_ENV
const char * name = key.s ? key.s : ""
const char * val = getenv(name)
 break

Detailed Description

Implements OP_ENV to read an environment variable by name.

Behavior:

  • Pops a string key from the stack and pushes the associated environment value as string.
  • If the variable is not set, pushes an empty string ("") rather than Nil.

Errors:

  • If the key is not a string, prints an error and terminates the VM with exit(1).

Definition in file env.c.

Function Documentation

◆ free_value()

free_value(key)
Here is the caller graph for this function:

◆ if()

if(key.type ! = VAL_STRING)

Definition at line 24 of file env.c.

Here is the call graph for this function:

◆ push_value()

push_value(vm,
make_string(val ? val :"") )

Variable Documentation

◆ break

break

Definition at line 34 of file env.c.

◆ name

const char* name = key.s ? key.s : ""

Definition at line 29 of file env.c.

◆ OP_ENV

case OP_ENV

Definition at line 22 of file env.c.

◆ val

const char* val = getenv(name)

Definition at line 30 of file env.c.