Environment Variable .env
A simple global string dictionary passed from parent process to child process upon invocation.
Storage method
- Kernel: Stored as null-terminated strings on the stack at execution time.
- Bash: Managed with a hash map stack structure, passed to children only when
export
ed.
- glibc: Array structure managed with
putenv
,getenv
(O(n) access).
- Python:
os.environ
wraps C'senviron
array but synchronization is not complete.
Regulation
- Names cannot contain
=
.
- POSIX reserves uppercase variable names for standard utilities, but lowercase names are allowed for application developers. In other words, lowercase names are perfectly fine.
- Single variable maximum 128 KiB, total environment including arguments 2 MiB.
Env Variable Managers