From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14124 invoked from network); 12 Dec 1998 07:47:03 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 12 Dec 1998 07:47:03 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id CAA28988; Sat, 12 Dec 1998 02:46:33 -0500 (EST) Resent-Date: Sat, 12 Dec 1998 02:46:33 -0500 (EST) From: "Bart Schaefer" Message-Id: <981211234519.ZM23754@candle.brasslantern.com> Date: Fri, 11 Dec 1998 23:45:19 -0800 In-Reply-To: <19981209194311.62754@athenaeum.demon.co.uk> Comments: In reply to Phil Pennock "PATCH: Docs out of sync" (Dec 9, 7:43pm) References: <19981209032532.54741@athenaeum.demon.co.uk> <9812090901.AA23162@ibmth.df.unipi.it> <19981209194311.62754@athenaeum.demon.co.uk> X-Mailer: Z-Mail (4.0b.820 20aug96) To: Phil Pennock , zsh-workers@math.gatech.edu Subject: Re: PATCH: Docs out of sync MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"5tlAP3.0.t47.PzXSs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4757 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Dec 9, 7:43pm, Phil Pennock wrote: } Subject: PATCH: Docs out of sync } } Typing away merrily, Peter Stephenson produced the immortal words: } > Phil Pennock wrote: } > > * bash has arrays. 'declare', 'local' & 'readonly' each accept '-a' to } > > declare an array. Is it reasonable to add '-a' to 'typeset'? This } > > would automatically duplicate the bash-ism. } > } > It's not exactly essential, since bash and zsh have rather different } > extensions to sh in any case. They're only similar in as much as they } > both include sh. It's hard enough keeping ksh emulation working. } } Looking through the source for 3.1.5-patched, bin_typeset et al accept } -a. This is undocumented. This functionality is not in 3.1.5. } With no arguments beyond the options, "typeset -a" scans the parameter } table for arrays. "typeset -A" scans for hashes. An added bonus! ;^) It was actually typeset -A that I was adding, and -a was the bonus. } Except that "typeset -a foo" is silently ignored. An unhandled case } later on. It's an unhandled case because the code (from prior to my patch) has an explicit on &= ~PM_ARRAY; in the loop that creates the parameters when they don't already exist. I think that's there because the syntax typeset array=(x y z) doesn't make it through the parser, but I don't know for sure so I didn't mess with it. Anyway, it's not correct to say that `typeset -a foo` is ignored -- it DOES create the parameter foo, but it creates it as a scalar, not as an array, which is exactly what used to happen with `typeset foo=(x y z)` before (x y z) started being interpreted as a glob modifier. (Now it says "unknown file attribute" and fails entirely.) } Scanning back, Bart added this functionality in patch 4608 (Nov 12). } It was documented in the article, but no docs patch. The options to } 'local' were also modified. I didn't give a doc patch because none of this stuff is stable yet; the syntax may change, etc. (Though `typeset -A` is unlikely to change, as it's ksh compatible.) } Docs patch included at end of this article. Thanks, but ... -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com