1

"How are shell variables related to the environment that a process started by the shell has on start-up?"

I read If processes inherit the parent's environment, why do we need export?

My current possibly wrong understanding is that shell variables aren't in the environment. Variables must be exported to the environment so a child can inherit them from a parent, but I don't see where start-up comes into play.

1

Your current understanding of "variables must be exported to the environment so a child can inherit them from a parent" seems correct to me.

Processes other than a shell have environment variables, the C language interface for this is getenv() and setenv(), from stdlib.h. Unix, Linux and *BSD operating system shells just happen to make environment variables look like ordinary, non-inherited shell variables.

So I guess that the answer to your specific question is: only shell variables that are exported to the shell's environment show up in a child process' environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.