pdksh(公共领域 kornShell)是否支持关联数组?
最近,我在做一些 bash shell 编程时遇到了困难,其中关联数组可以解决我的问题。 我在 google 上搜索了 KornShell (ksh) 的功能,了解到它支持关联数组,因此我安装了 Cygwin 的 pdksh(公共领域 KornShell)。
但是,当尝试以规定的方式(typeset -A varName)创建关联数组时,我收到以下错误,因此我开始怀疑 pdksh 不支持关联数组。
./find_actions.ksh: line 2: typeset: -A: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
我想我会考虑 Perl,但我真的想要一个很好的借口来学习对我来说新的方言/语言。
I recently ran up against a wall doing some bash shell programming where an associative array would have solved my problems. I googled about features of the KornShell (ksh) and learned that it supports associative arrays, so I installed Cygwin's pdksh (Public Domain KornShell).
However, when trying to create an associative array in the prescribed manner (typeset -A varName), I received the following errors, so I'm beginning to suspect pdksh does not support associative arrays.
./find_actions.ksh: line 2: typeset: -A: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
Guess I will be considering Perl instead, but I really wanted a good excuse to learn a dialect/language new to me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看一下 ksh93,它支持关联数组,并且是 ksh 更完整/正确的实现。
请参阅:kornshell.com
Take a look at ksh93, it supports associative arrays and is a much more complete/correct implementation of ksh.
See: kornshell.com
pdksh 不支持关联数组; 这是它的后继者 mksh 的一个有计划且明确的功能(一旦我开始实际实现它,那就是……抱歉,速度很慢)。
pdksh doesn't have any support for associative arrays; it’s a planned and definite feature of its successor, mksh (as soon as I get around to actually implementing it, that is… sorry for being slow with that).
为什么不直接使用 bash? 它可能没有显式关联数组,但您可以 伪造它们。
或者,zsh 具有出色的关联数组支持。
Why not just use bash? It might not have explicit associative arrays, but you can fake them.
Alternatively, zsh has excellent associative array support.