[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to add dir to path



On Tue, Aug 07, 2007 at 06:24:08PM +0200, Manon Metten wrote:
> Hi Mike,
> 
> On 8/7/07, Mike McCarty <Mike.McCarty@sbcglobal.net> wrote:
> 
> Do something like this
> >
> > $ export PATH=~/scripts:$PATH
> >
> > If you put it into the appropriate startup script it will get done
> > every time.
> 
> 
> 
> I was looking for some kind of 'path' command but could not find anything
> alike. I didn't know of 'export'.

$PATH is an environment variable like any other and gets assigned a
value in the same way as any other. export is used to make a variable
available to other processes that come after the one spawned by the
assignment process. Thus any process that is a child of the parent of
the export statement gets access to that variable. 
so this is just three actions jammed together and its processed in a way
better expressed like this:

export ( assign the value of (concatenating ~/script: and ( the expanded
value of PATH )) to PATH )

using standard mathematical parenthesis precedence. 

start with the inner parenthesis: expand the value of PATH, that is
what PATH is current assigned. Next parenthesis, concatenate ~/script:
and the previous result (the value of PATH). Next parenthesis, assign
the previous result (concatenationg) to the variable PATH. Next
parenthesis, export that value to the next level up in the hierarchy
so that other processes can access it. 

This assignment will only exist in the shell in which it
executed. When you exit that shell, it will disappear along with that
shell.  That's why you put somewhere where it will get started for
every shell...

A

next comes lisp ;)

Attachment: signature.asc
Description: Digital signature


Reply to: