Tíquete #39386

'typeset' and family accept invalid identifiers

: 2019-07-10 04:51 Última Atualização: 2019-07-11 00:52

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

Details

$ readonly a\ b=c
$ readonly a\ b=d
readonly: $a b is read-only
$ echo ${a b}
syntax error: invalid character ` ' in parameter expansion

If that is an invalid expansion, then 'readonly' should not have succeeded either.

$ export a\ b=c
$ env | grep ^a\ b=
a b=c

Allowing identifiers with spaces to be exported also does not seem like a good thing.

Ticket History (2/2 Histories)

2019-07-10 04:51 Updated by: mcdutchie
  • New Ticket "'typeset' and family accept invalid identifiers" created
2019-07-11 00:52 Updated by: magicant
Comentário

But GNU's env command supports space-including variable names and POSIX does not seem to disallow such behavior.

$ env 'a b=c' printenv 'a b'
c

I would rather think the shell should support parameter expansion with arbitrary names, if anything should be fixed.

Attachment File List

No attachments

Editar

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