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
env VAR=panda ./myprogram
myprogram’s environment (but not in the current