Setting the path in bash_profile

Why does setting PATH require :${PATH} at the end?

 PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" 

When I add a path to this, I would do

 PATH=$PATH:... 

How to add PATH without going to a new line. That is, how to add app PATH to the original PATH statement.

If I wanted, for example, put the next line in the first line. How does this interact with the part :${PATH} ?

 PATH=$PATH:/usr/local/mysql/bin 
+6
source share
1 answer

There is a difference between adding an existing path to the front or end of the $PATH environment variable. The bash path allows execution paths starting from the front of the list. This means that if you have these two directories in your path:

 PATH="/dir1/bin:/dir2/bin" 

And they both have executable test.sh in it, then when you run test.sh it will execute one of /dir1/bin/test.sh , since this directory appears first in the path.

In addition, ${PATH} matches $PATH .

 PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" 

just adds /Library/Frameworks/Python.framework/Versions/2.7/bin to the beginning of the path and

 PATH=$PATH:/usr/local/mysql/bin 

just adds /usr/local/mysql/bin to the end of the path.

So how do you do both on the same line? Something like that:

 PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}:/usr/local/mysql/bin" 
+16
source

Source: https://habr.com/ru/post/955431/


All Articles