From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2775 invoked from network); 30 Jul 1997 06:19:19 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 30 Jul 1997 06:19:19 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.8.5/8.8.5) id CAA29967; Wed, 30 Jul 1997 02:11:27 -0400 (EDT) Resent-Date: Wed, 30 Jul 1997 02:11:27 -0400 (EDT) From: "Bart Schaefer" Message-Id: <970729231110.ZM19573@candle.brasslantern.com> Date: Tue, 29 Jul 1997 23:11:10 -0700 In-Reply-To: <199707300516.BAA01180@hzoli.home> Comments: In reply to Zoltan Hidvegi "Re: RC_EXPAND_PARAM bug" (Jul 30, 1:16am) References: <199707300516.BAA01180@hzoli.home> X-Mailer: Z-Mail (4.0b.820 20aug96) To: Zoltan Hidvegi Subject: Re: RC_EXPAND_PARAM bug Cc: zsh-workers@math.gatech.edu (Zsh hacking and development) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"F6zxn.0.7K7.Fijtp"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3392 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Jul 30, 1:16am, Zoltan Hidvegi wrote: } Subject: Re: RC_EXPAND_PARAM bug } } > I'm still not comprehending this. } } OK, I tell you what subst.c does. Thank you! } prefix${^a}suffix } } Suppose that prefix does not have anything to expand. paramsubst is } called to expand this string, which expands ${^a}. There are three } cases: } } 1. `a' was an empty array. In that case the expansion is the empty list, } and suffix is not evaluated (so even if there is a $[i++] in suffix, i } will not change). Hrm. I think I would have expected to get prefixsuffix, with suffix evaluated. That's what you get when a=("") or a="", but I can't decide if that represents an argument in favor, or against. } 3. `a' has more than one elements. In that case stringsubst is called } for suffix alone (which may call paramsubst again to expand something } in suffix), and the result will be be a list. This list is combined } with the expansion of ${^a}. If suffix expands to an empty list, the } result will be empty Again I find the empty list behavior unexpected, but possibly defensible. } This guarantees left to right evaluation, everything is evaluated at most } once, These are both good things. } and everything is evaluated once unless there is an rc-expansion of } an empty array which discards everything following that array. It's that one that gives me pause. } What would be the preferred evaluation of ${^a}1${^^x}? What does the real "rc" shell do? Duplicating it would be my first choice, unless it does something wildly different than any previous version of zsh. } Alternatives: } } 1. a1x ay b1x by (current) } } 2. a1x y b1x y (beta16 and older) } } 3. a1x b1x y (just an other logical solution). The important question for me is, where are the word breaks in (2)? That is, if I do: z=(${^a}1${^^x}) What is ${#z}? If z is ("a1x y" "b1x y"), then I think that's wrong. I presume you mean 4 words, though, in which case I think it's right, in spite of what I just told Geoff. :-} On Jul 30, 9:46am, Andrej Borsenkow wrote: } Subject: Re: RC_EXPAND_PARAM bug } } zsh-3.1.2 with RC_EXPAND_PARAM bugfix. } } % echo ${^a}1${^^x} } a1x ay b1x by } } % echo ${^^a}1${^x} } a b1x b1y } } It looks illogical. Either the latter should be 'ax b1x ay b1y' or the } former 'a1x b1x y'. I agree with Andrej on that. If you're going to map over lists, you have to map over them in the prefix too, not just in the suffix. However, I don't like the behavior of (3), i.e. that when ${x} is a list then the word break interrupts the rc-expansion. I'd prefer that the expansion proceed across the suffix in the same way regardless of whether x is an array or a string, and then introduce the word breaks at the end. That's why I prefer (2) -- but I'd still like to know how "rc" does it. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com