I can write
VAR=$VAR1
VAR=${VAR1}
VAR="$VAR1"
VAR="${VAR1}"
the end result to me all seems about the same. Why should I write one or the other? are any of these not portable/POSIX?
|
I can write
the end result to me all seems about the same. Why should I write one or the other? are any of these not portable/POSIX? |
||||
|
|
|
Using quotes around a variable as in
On portability: According to POSIX.1-2008 section 2.6.2, the curly braces are optional. |
|||||||||||||
|
|
In a variable assignment, field splitting (i.e. splitting at whitespace in the value) and pathname expansion (i.e. globbing) are turned off, so You do need the double quotes in other cases, in particular in |
|||||
|