The first thing that the shell does it to split the line on unquoted spaces (metacharacters) into tokens. This is different than the word-splitting done after expansions in that the IFS value is not used. The characters used for initial token splitting are fixed as metacharacters. All this will make var
contain Hello
(sometimes for a brief moment):
var=Hello echo World # Space
var=Hello;echo World # Semicolon
var=Hello echo World # Tab
var=Hello&echo World # Ampersand
Also, for this initial token splitting, the right side of an assignment is considered quoted.
All this are equivalent:
var="Hello World"
var='Hello World'
var=Hello\ World
Note that the only character that must be quoted is the white space. Even if IFS is modified.
Of course, inside double quotes several expansions are allowed:
var=~"/" ; var=~/ tilde expansion (outside quotes)
var="$PWD" ; var=$PWD parameter and variable expansion
var="$(pwd)" ; var=$(pwd) command substitution
var="$((2+3))" ; var=$((2+3)) arithmetic expansion
var="!$" ; var=!$ history substitution
All pairs above are equivalent (the same).
None of the pairs will work the same inside single quotes (or with some back-quotes), example:
var='$PWD' ; var=\$PWD
Also, this are not equivalent:
var="( Hello World )" ; var=( Hello World )
The parenthesis trigger an array assignment
So, all this are equivalent:
var=hi
var="hi"
var='hi'
var=\hi
var=h\i
var=\h\i
taking into account the special conditions given previously.
x="foo" ; x=hi echo hello ; echo "$x"
#will print hello, then foo (not hi) – Olivier Dulac Jan 07 '18 at 21:59