Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Enable further expansion of parameter name by ${!...}
- X-seq: zsh-workers 34392
- From: ZyX <kp-pav@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Tomoki Sekiyama <tomoki.sekiyama@xxxxxxxxx>, "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] Enable further expansion of parameter name by ${!...}
- Date: Sun, 25 Jan 2015 23:38:51 +0300
- 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=
- In-reply-to: <150125122410.ZM31619@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1422177338-85472-1-git-send-email-tomoki.sekiyama@gmail.com> <150125122410.ZM31619@torch.brasslantern.com>
25.01.2015, 23:25, "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>:
> 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;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author