0

I'm looking at my bash profile and not really understanding what I see. I think I see a variable (PATH) being redeclared - though this can't be true as all my programs seem to work. Can you help me by talking me through what is going on?

here is part of my bash_profile:

export PATH="$HOME/.phpenv/bin:$PATH"
eval "$(phpenv init -)"

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"

#Added for mysql installation by me
export PATH="/usr/local/mysql/bin:$PATH"
0

The commands are run sequentially, each adding the previous value of $PATH to the end of the new path part. For example, if the value of $PATH right before line 5 is

"~/.phpenv/bin:/usr/bin:/bin"

then the right-hand side of line 5 it will be expanded to

"/usr/local/heroku/bin:~/.phpenv/bin:/usr/bin:/bin"

and $PATH will be overwritten with this new value.

  • thanks. I'm still not sure how that is working. what does the colon do? – Zach Smith Jun 16 '14 at 8:01
  • @ZachSmith: It does nothing; it's merely part of the value. (The syntax of a $PATH value is a colon-delimited list of directories.) – grawity Jun 16 '14 at 8:57
  • ok thanks. so then that is a list of paths? so then i guess I have one more question :p. how do applications know which path value to use or do they just cycle through them until they find one that works? – Zach Smith Jun 16 '14 at 10:20
  • 1
    Yes, your shell starts from the beginning of the list and runs the first executable file it finds with the name of the command you typed. – Vortico Jun 16 '14 at 16: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.