待辦事項 #39386

'typeset' and family accept invalid identifiers

啟用日期: 2019-07-10 04:51 最後更新: 2019-07-11 00:52

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

細節

$ 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
評語

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

編輯

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