Associative Arrays Still in the Future? Yuck!
Posted Aug 6, 2004 0:04 UTC (Fri) by AnswerGuy
Parent article: Bash 3.0 released
Korn shell has had support for associative arrays (which python calls "dictionaries," and perl "hashes") for eons (well over a decade I think).
I'll also be interested in whether bash 3.x fixes one shortcoming of bash that's been around forever. Consider the following:
unset foo; echo bar | read foo; echo $foo
What should the output be?
In zsh and ksh you'll see that foo is set; they spawn the subshells to the left of the pipe. In bash you'll find it unset because the read occurs in a subshell which exits at the semicolon. (Thus necessitating braces or parents to group the part after the pipe; or force them all into yet another, explicit subshell).
To most shell scripters this is obscure; nobody cares. However, for serious shell scripting this sort of thing is important (not so much for reading values from subprocesses into single variables, but for reading multiple variables parsed on $IFS, for example).
(Yes, I know, most UNIX/Linux admins and programmers would counter that serious scripting isn't done in shell --- that "real programmers" (and scripters) use Perl. To which I can only respond: "Foo!"
to post comments)