tilde expansion active in quoted parameter substitution
Thanks for reporting.
Looks like this is the same kind of issue as #36278. POSIX does not precisely define how double-quotes modify interpretation of other special characters.
The behavior of other shells is consistent for "${unset-~}", "${unset+~}", and "${unset=~}", but for "${unset?~}"...
+ bash -o posix -c 'echo ${unset?~}' bash: unset: /home/magicant + bash -o posix -c 'echo "${unset?~}"' bash: unset: /home/magicant + ksh -c 'echo ${unset?~}' ksh: unset: /home/magicant + ksh -c 'echo "${unset?~}"' ksh: unset: ~ + mksh -o posix -c 'echo ${unset?~}' mksh: unset: /home/magicant + mksh -o posix -c 'echo "${unset?~}"' mksh: unset: ~ + zsh --emulate sh -c 'echo ${unset?~}' zsh:1: unset: ~ + zsh --emulate sh -c 'echo "${unset?~}"' zsh:1: unset: ~
Korn shell is quite strange in that tilde expansion is enabled in "${foo#~}" but not in "${foo##~}".
The attached patch should fix this.
On second thought, however, I'm in doubt whether this should be really "fixed." POSIX explicitly says, "In each case that a value of word is needed (based on the state of parameter, ...), word shall be subjected to tilde expansion, parameter expansion, command substitution, and arithmetic expansion." (XCU 2.6.2) POSIX does not explicitly require tilde expansion be disabled in quoted expansion. Then what interpretation of POSIX can deny the current behavior of yash?
I'm postponing this, maybe until POSIX is revised for clarity.
Quoting should deactivate tilde expansion, but yash still expands tildes in quoted parameter expansions.
Expected output: ~/test (as per dash, bash, *ksh, zsh)