待辦事項 #38728

tilde expansion active in quoted parameter substitution

啟用日期: 2018-11-06 05:48 最後更新: 2018-11-26 00:19

回報者:
負責人:
類型:
狀態:
開啟 [Owner assigned]
元件:
里程碑:
(無)
優先權:
3
嚴重程度:
5 - 中
處理結果:
Postponed
檔案:
1
Vote
Score: 0
No votes
0.0% (0/0)
0.0% (0/0)

細節

Quoting should deactivate tilde expansion, but yash still expands tildes in quoted parameter expansions.

$ yash -c 'unset foo; echo "${foo:-~/test}"'
/Users/martijn/test

Expected output: ~/test (as per dash, bash, *ksh, zsh)

Ticket History (3/6 Histories)

2018-11-06 05:48 Updated by: mcdutchie
  • New Ticket "tilde expansion active in quoted parameter substitution" created
2018-11-07 23:30 Updated by: magicant
評語

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.

2018-11-25 17:01 Updated by: magicant
評語

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: ~
2018-11-25 23:23 Updated by: magicant
評語

Korn shell is quite strange in that tilde expansion is enabled in "${foo#~}" but not in "${foo##~}".

2018-11-26 00:19 Updated by: magicant
  • 優先權 Update from 5 - 中 to 3
  • 元件 Update from (無) to shell-main
  • 處理結果 Update from to Postponed
  • 負責人 Update from (無) to magicant
評語

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.

編輯

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » 登入