After alias substitution is performed, each word is checked to see if it begins with an unquoted ∼. For tilde substitution, word also refers to the word portion of parameter expansion (see Parameter Expansion below). If it does, then the word up to a / is checked to see if it matches a user name in the password database (often the /etc/passwd file). If a match is found, the ∼ and the matched login name are replaced by the login directory of the matched user. If no match is found, the original text is left unchanged. A ∼ by itself, or in front of a /, is replaced by $HOME. A ∼ followed by a + or - is replaced by the value of $PWD and $OLDPWD respectively.
In addition, when expanding a variable assignment, tilde substitution is attempted when the value of the assignment begins with a ∼, and when a ∼ appears after a :. The : also terminates a ∼ login name.
3.145.169.109