Tíquete #38728

tilde expansion active in quoted parameter substitution

: 2018-11-06 05:48 Última Atualização: 2018-11-26 00:19

Relator:
Dono:
Tipo:
Estado:
Aberto [Owner assigned]
Componente:
Marcos:
(Nenhum)
Prioridade:
3
Gravidade:
5 - Medium
Resolução:
Postponed
Arquivo:
1
Vote
Score: 0
No votes
0.0% (0/0)
0.0% (0/0)

Details

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
Comentário

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
Comentário

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
Comentário

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
  • Prioridade Update from 5 - Medium to 3
  • Componente Update from (Nenhum) to shell-main
  • Resolução Update from Nenhum to Postponed
  • Dono Update from (Nenhum) to magicant
Comentário

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.

Editar

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