Env Variable

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2022 Nov 30 18:15
Editor
Edited
Edited
2026 Jan 19 16:56
Refs
Refs

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 exported.
  • glibc: Array structure managed with putenv, getenv (O(n) access).
  • Python: os.environ wraps C's environ 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
 
 
 
 
Environment variables are a legacy mess: Let's dive deep into them
Programming languages have rapidly evolved in recent years. But in software development, the new often meets the old, and the scaffolding that OS gives for running new processes hasn’t changed much since Unix. If you need to parametrize your application at runtime by passing a few ad-hoc variables (without special files or a custom solution involving IPC or networking), you’re doomed to a pretty awkward, outdated interface:
Environment variables are a legacy mess: Let's dive deep into them
 
 

Recommendations