1

I'm on a Mac, but this seems like a UNIX/Linux question. I just installed Postgres.app, and the documentation says to add the /bin directory that ships with Postgres.app to your PATH by adding the following line to .bashrc, it'll get set for every terminal session:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

Should I be exporting that, or just keep it as is?

Timo
  • 6,332
ivan
  • 1,878
  • 1
    I think you should do an export of the PATH – Boogy Jan 23 '14 at 07:17
  • @Chris That is about dir:$PATH versus $PATH:dir, while this question is about export PATH= versus PATH=. Still a duplicate of another question though. -edit- only now I see this question is much older – Bernhard Jun 22 '14 at 12:09
  • Yes, use export, but first read: http://unix.stackexchange.com/questions/124444/how-can-i-cleanly-add-to-path – goldilocks Jun 22 '14 at 15:54

1 Answers1

1

export puts the variable in the program environment, which is propagated to forked processes. If you want any processes you launch to know about the new location, you need to export it (although if it is already exported, you don't need to use export again, but it does no harm to do so).

If you want to be totally sure, export it. If it is already in your environment, though, you do not need to do it again.

Chris Down
  • 125,559
  • 25
  • 270
  • 266
  • Once a variable is exported, it stays exported, and further assignments modify the environment variable. So export isn't actually needed there. Timo's (deleted) answer is correct regarding this. – Gilles 'SO- stop being evil' Jun 22 '14 at 11:21
  • @Gilles That's what I said in the parenthesized sentence. Did I say something in this answer that you think contradicts that? I can't see anywhere I suggested otherwise, unless you're referring to my advice to export it anyway, which is just to avoid missing the export in environments without a PATH to begin with. – Chris Down Jun 22 '14 at 11:30
  • “The answer is probably yes” — actually, the answer is probably no. By the way, do you have an opinion on closing this as a duplicate of http://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path (which answers this but is more general so the answer is buried in other considerations)? http://chat.stackexchange.com/transcript/message/16211821#16211821 – Gilles 'SO- stop being evil' Jun 22 '14 at 11:32
  • @Gilles The question is "should I", not "do I have to". I take "should I" to mean "does it decrease the likelihood of something unexpected happening", not "is it typically necessary". I would support closing as a duplicate, yes. – Chris Down Jun 22 '14 at 11:35