0

This question already has an answer here:

regarding the file: .bash_profile

what is the different between

 PATH=${PATH}:${HOME}/bin:/usr/local/

to

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

and what is the correct syntax?

marked as duplicate by Gilles, Thomas Dickey, Jeff Schaller, Eric Renouf, Stephen Harris Sep 19 '16 at 0:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • In this case, both are equivalent – GMaster Sep 18 '16 at 10:19
1

I'm guessing they are both equivalent, when a variable is used in the form:

${HOME}

the curly braces serve to delimit the variable WORD when it would otherwise be indistinguishable from another WORD directly adjacent. e.g.

echo $HOMEahoy

would produce nothing (except the newline from the echo)

echo ${HOME}ahoy 

would echo your home path like you expect plus ahoy.
I suspect in this case the {} are unnecessary because =:/ are likely not valid variable characters in bash so, bash can work out the WORD boundaries itself.
When shell scripting, if in doubt I always put in the curly braces.
The idea is not limited to bash e.g. PHP has similar behaviours - except in PHP they take a slightly different form e.g. {$VAR_NAME}

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