Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Ubuntu User (http://www.linux-archive.org/ubuntu-user/)
-   -   How to set an environment variable question (http://www.linux-archive.org/ubuntu-user/624004-how-set-environment-variable-question.html)

Ioannis Vranos 01-22-2012 06:45 PM

How to set an environment variable question
 
Hi all.

I have seen 2 versions for the following:

export PATH=$PATH:/some_directory

and

export PATH=${PATH}:/some_directory


Is anyone of them better than the other? Or in other words, are '{'
and '}' redundant? (I don't know shell programming).


Thank you a lot,

--
Ioannis Vranos

http://cppsoftware.binhoster.com

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

Nils Kassube 01-22-2012 08:57 PM

How to set an environment variable question
 
Ioannis Vranos wrote:
> I have seen 2 versions for the following:
>
> export PATH=$PATH:/some_directory
>
> and
>
> export PATH=${PATH}:/some_directory
>
>
> Is anyone of them better than the other? Or in other words, are '{'
> and '}' redundant? (I don't know shell programming).

In this case there is no difference. Braces are useful if you want to
mix variables and text. Try this to see the difference:

a=hell
echo $ao
echo ${a}o

The first echo command has no output because the variable "ao" is
undefined (unless you have set it for some reason). The second echo
command uses the contents of variable "a" and appends an "o".


Nils

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users


All times are GMT. The time now is 11:18 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.