Hello, there seem to be some situations where the tilde is not expanding despite being unquoted. For example :- % print -r ~\ ; print -r ~~ ; print -r ~\\ ; ~ ~~ ~\ It seems quoting a character here is also quoting the preceding tilde sign, except for ~~ which is being quoted despite no \ , ‘ or “. Turning on xtrace confirms that these are being quoted :- % (set -x ; print -r ~\ ; print -r ~~ ; print -r ~\\ ) +zsh:1> print -r '~ ' ~ +zsh:1> print -r '~~' ~~ +zsh:1> print -r '~\' ~\ Similar behaviour in scripts ------------------ #!/bin/zsh print -r ~\ print -r ~~ print -r ~\\ % ./script.sh ~ ~~ ~\ ------------------ Same behaviour with :- % print -r ~'*' ~* % print -r ~'@' ~@ % print -r ~'%' ~% % print -r ~' ' ~ % print -r ~# ~# And also with double quotes instead of single quotes. Yet, the tilde expands in the following :- % print -r ~'/' /Users/username/ % print -r ~'/path/to/file' /Users/username/path/to/file % print -r ~\/ /Users/username/ The documentation says :- Each word is checked to see if it begins with an unquoted ‘~’. If it does, then the word up to a ‘/’, or the end of the word if there is no ‘/’, is checked to see if it can be substituted in one of the ways described here. If so, then the ‘~’ and the checked portion are replaced with the appropriate substitute value. A ‘~’ by itself is replaced by the value of $HOME. ------ It appears that a ~ if followed by a quoted character only expands if that character is ‘/‘. And no expansion occurs if tilde is immediately followed by @,#,%,=,^… quoted or unquoted. Can someone confirm what’s going on here ? Thanks. |