Setting environment variable in ZSH gives number expected

99封情书 提交于 2019-12-04 07:34:47

You can't export an array in zsh.

For more info: http://zsh.sourceforge.net/Guide/zshguide02.html

Note that you can't export arrays. If you export a parameter, then assign an array to it, nothing will appear in the environment; you can use the external command printenv VARNAME' (again no$' because the command needs to know the name, not the value) to check. There's a more subtle problem with arrays, too. The export builtin is just a special case of the builtin typeset, which defines a variable without marking it for export to the environment. You might think you could do

typeset array=(this doesn\'t work)

but you can't --- the special array syntax is only understood when the assignment does not follow a command, not in normal arguments like the case here, so you have to put the array assignment on the next line. This is a very easy mistake to make. More uses of typeset will be described in chapter 3; they include creating local parameters in functions, and defining special attributes (of which the `export' attribute is just one) for parameters.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!