export which is correct syntax

Suvayu Ali fatkasuvayu+linux at gmail.com
Sat Jan 4 15:08:17 UTC 2014


On Sat, Jan 04, 2014 at 10:37:48PM +1030, Tim wrote:
> Frank Murphy:
> > > 1: export TMPDIR=/var/tmp
> > > 2: export TMPDIR=$TMPDIR:/var/tmp
> 
> Suvayu Ali:
> > Depends on what you want to do.  If you want to overwrite the variable,
> > use (1).  If you want to add (prepend) to the variable, use (2).
> 
> Wouldn't that actually be an append - add onto the end of the existing
> variables, as opposed to insert before the existing variables (prepend).

This would be append:

3: export TMPDIR=/var/tmp:$TMPDIR

This is how I understand it; if a matching path is found, it is
considered for the task at hand.  So prepend (front) would mean "I want
this to be considered before everything else", whereas append (back)
would mean "I want this to be considered when everything else fails".

The easiest example to see it in action is the PATH variable.

Does that make sense?

-- 
Suvayu

Open source is the future. It sets us free.


More information about the users mailing list