0

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?

yael
  • 1,521

1 Answers1

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}