1

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.

javaPlease42
  • 4,699
  • 7
  • 36
  • 65
Dexygen
  • 12,287
  • 13
  • 80
  • 147

3 Answers3

1

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).

mirabilos
  • 5,123
  • 2
  • 46
  • 72
1

Take a look at ksh93, it supports associative arrays and is a much more complete/correct implementation of ksh.

See: kornshell.com

Darron
  • 21,309
  • 5
  • 49
  • 53
0

Why not just use bash? It might not have explicit associative arrays, but you can fake them.

Alternatively, zsh has excellent associative array support.

Alastair
  • 4,475
  • 1
  • 26
  • 23