RFC: proposed new builtin for /bin/sh (associative arrays)

Peter Pentchev roam at ringlet.net
Fri Oct 31 02:58:28 PST 2003


On Fri, Oct 31, 2003 at 01:43:31AM -0800, Luigi Rizzo wrote:
[snip description of a new 'indexes' builtin]
> Any comments ? Is this interesting enough to be committed
> (with a proper manpage description) ?
> I could provide a flag to "indexes" to return the values instead
> of the names, but i believe this form is more useful.

Just a minor suggestion: could this be done as another form of variable
expansion instead of as another keyword?  Rationale: bash already does
this - from the 'EXPANSION' section of its manpage:

  ${!prefix*}
      Expands to the names of variables whose names begin with prefix,
      separated by the first character of the IFS special variable.

Thus, 'indexes foo_' would be equivalent to '${!foo_*}'.

What you've done is great - several times I've found myself wishing that
our sh had this, especially after finding that bash does it - but
wouldn't it be better not to introduce a gratuitious syntax
incompatibility if we can help it? :)

G'luck,
Peter

-- 
Peter Pentchev	roam at ringlet.net    roam at sbnd.net    roam at FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
If this sentence were in Chinese, it would say something else.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20031031/af3ce773/attachment.bin


More information about the freebsd-hackers mailing list