From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6443 invoked by alias); 25 Jan 2015 20:39:04 -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: 34392 Received: (qmail 26315 invoked from network); 25 Jan 2015 20:39:01 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_FSL_HELO_BARE_IP_2 autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1422218331; bh=pQKV67dzkE7GLi5VrcrZvMNARBERmcEJBl7khQgLwt4=; h=From:To:In-Reply-To:References:Subject:Date; b=NSlixOo98ZKxN07KA6Cu05ayl+z7qxwyuseq/jlt+jiqnriIN2am+CQmkgbEosguz CHUaNAtoKdVLR9qMM7YSJB/s1vqFmGfFO2A3cD1bmG5eCNvtDWZrhu3mMFE6bXF6WP J5O/Rf2Kb7dd3XvNpNzCHAgy8YMZ9MlH2m3VN78I= From: ZyX To: Bart Schaefer , Tomoki Sekiyama , "zsh-workers@zsh.org" In-Reply-To: <150125122410.ZM31619@torch.brasslantern.com> References: <1422177338-85472-1-git-send-email-tomoki.sekiyama@gmail.com> <150125122410.ZM31619@torch.brasslantern.com> Subject: Re: [PATCH] Enable further expansion of parameter name by ${!...} MIME-Version: 1.0 Message-Id: <10496951422218331@web21g.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Sun, 25 Jan 2015 23:38:51 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 25.01.2015, 23:25, "Bart Schaefer" : > On Jan 25,  4:15am, Tomoki Sekiyama wrote: > } Subject: [PATCH] Enable further expansion of parameter name by ${!...} > } > } With this change, ${!...} will enable further expansion of parameter name, > } which is equivalent to (P) expansion flag. This will enable zsh to run some > } scripts using variable references for bash. > > Don't we already have something like this for ksh emulation?  Except that > it acts like (k) instead of like (P)?  Although I can't find this in the > documentation anywhere, right at the moment. I have ksh installed and here `${!VAR}` outputs `VAR` regardless of whether $VAR is defined and what type and what value does it have. [Manual page][1] says that it should actually expand to “the name of the variable referred to by vname” and says that this will be `VAR` unless it is a name reference (I have only tried strings, arrays and associative arrays). [1]: http://unixhelp.ed.ac.uk/CGI/man-cgi?ksh+1 > > I'm not going to commit this without some more discussion, though, because > it seems a bit iffy to have exactly the same syntax mean two such very > different things.  At the very least perhaps both branches should depend > on emulation modes rather than having the bash behavior become a default. > > diff --git a/Src/subst.c b/Src/subst.c > index a2bb648..882e62c 100644 > --- a/Src/subst.c > +++ b/Src/subst.c > @@ -1734,8 +1734,11 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags) >           * doesn't have parameter flags it might be neater to >           * handle this with the ^, =, ~ stuff, below. >           */ > - if ((c = *s) == '!' && s[1] != Outbrace && EMULATION(EMULATE_KSH)) { > -    hkeys = SCANPM_WANTKEYS; > + if ((c = *s) == '!' && s[1] != Outbrace) { > +    if (EMULATION(EMULATE_KSH)) > + hkeys = SCANPM_WANTKEYS; > +    else /* emulate bash equivalent to our (P) */ > + aspar = 1; >              s++; >          } else if (c == '(' || c == Inpar) { >              char *t, sav;