Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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 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 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 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 at 16:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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