From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13880 invoked by alias); 27 Jan 2015 05:48:53 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34408 Received: (qmail 12439 invoked from network); 27 Jan 2015 05:48:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=QM3fnbPO c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=YNv0rlydsVwA:10 a=iVuNZjVXLqqM4V6tf7MA:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <150126214831.ZM551@torch.brasslantern.com> Date: Mon, 26 Jan 2015 21:48:31 -0800 In-reply-to: Comments: In reply to Tomoki Sekiyama "Re: [PATCH] Enable further expansion of parameter name by ${!...}" (Jan 26, 3:00pm) References: <1422177338-85472-1-git-send-email-tomoki.sekiyama@gmail.com> <150125122410.ZM31619@torch.brasslantern.com> <10496951422218331@web21g.yandex.ru> <150125133931.ZM32124@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "zsh-workers@zsh.org" Subject: Re: [PATCH] Enable further expansion of parameter name by ${!...} Cc: Tomoki Sekiyama MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jan 26, 3:00pm, Tomoki Sekiyama wrote: } } # ksh bash zsh(default) zsh(KSH) } echo $aaa # bbb bbb bbb bbb } echo ${!aaa} # aaa ccc bad substitution bbb OK, but the point is that ideally in that last row the zsh(KSH) case would be "aaa". I guess this is no worse than the difference of ${array[1]} with or without ksharrays set. (If "nameref aaa=bbb", then the first column of the last row would be "bbb".) } # ksh bash zsh(default) zsh(KSH) } echo ${!foo[bar]} # foo[bar] piyo bad substitution bar I find this one interesting, because the ksh doc says it "expands to the name of the subscript" which would seem to me to fit the zsh(KSH) column more than the ksh column. Ksh also has the special case ${!foo[bar..baz]} which treats the array keys as an alphabetical list and generates a sub-list of them from "bar" through "baz" (uninteresting in this example). } According to this, introducing bash-like behaviors instead of "bad } substitution" error will not hurt zsh even in ksh emulation mode. My question is, why choose the bash behavior for the zsh default and not the ksh behavior? If we make the bash behavior the default, then also adding namerefs as a default leaves us deviating from ksh on the meaning of ${!aaa} for identifiers that are not namerefs.