Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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"
share|improve this question
up vote 0 down vote accepted

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.

share|improve this answer
    
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .