User: Password:
|
|
Subscribe / Log in / New account

Associative Arrays Still in the Future? Yuck!

Associative Arrays Still in the Future? Yuck!

Posted Aug 6, 2004 0:04 UTC (Fri) by AnswerGuy (subscriber, #1256)
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!"

JimD


(Log in to post comments)


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds