1

I still struggle with understanding the export command.

I know that it is for making variables, which are defined in a console or script, available to child processes of the console / script.

But what I'm not sure about is:

Will the variable be available only in child processes which are started after the export command has been executed?

Or will be variable become available in already started child processes too?

3

Will the variable be available only in child processes which are started after the export command has been executed?

Yes.

will be variable become available in already started child processes too?

No.


bash or any other shell reads statements line by line and executes them as it moves further, so any export-ed variable would be available only to the statements (child processes if that matters) that come after the export.

1
  • Makes sense according what I know so far. The bash is an interpreter which processes every command / code line it gets provided. It compiles the line, sends it to the CPU for execution and then done. Means: The child process will be started and then it lives in it's own environment. Thanks a lot. – mizech May 25 '17 at 12:47

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.