read the transcript!
panel 1: every process has environment variables
how to see any process’s environment variables on Linux:
cat /proc/$PID/environ | tr '\0' '\n'
panel 2: shell scripts have 2 kinds of variables
- environment variables
- shell variables
unlike in most languages, in shell you access both of these in the exact same way:
panel 3: export sets environment variables
export ANIMAL=panda means that every child process will have
ANIMAL set to
panel 4: child processes inherit environment variables
this is wy the variables set in your
.bash_profile work in all programs you start from the terminal. They’re all child processes of your bash shell!
panel 5: shell variables aren’t inherited
in this example,
$var only gets set in this process, not in child processes
panel 6: you can set environment variables when starting a program
Illustration of a smiling stick figure with curly hair, talking to env, represented by a box with a smiley face.
env VAR=panda ./myprogram
env: OK! I’ll set
panda and then start