zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Tomoki Sekiyama <tomoki.sekiyama@gmail.com>, zsh-workers@zsh.org
Subject: Re: [PATCH] Enable further expansion of parameter name by ${!...}
Date: Sun, 25 Jan 2015 12:24:10 -0800	[thread overview]
Message-ID: <150125122410.ZM31619@torch.brasslantern.com> (raw)
In-Reply-To: <1422177338-85472-1-git-send-email-tomoki.sekiyama@gmail.com>

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'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;


  parent reply	other threads:[~2015-01-25 20:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-25  9:15 Tomoki Sekiyama
2015-01-25 18:14 ` Peter Stephenson
2015-01-25 18:23   ` Mikael Magnusson
2015-01-25 20:24 ` Bart Schaefer [this message]
2015-01-25 20:38   ` ZyX
2015-01-25 21:39     ` Bart Schaefer
2015-01-26 20:00       ` Tomoki Sekiyama
2015-01-26 20:44         ` ZyX
2015-01-27  5:48         ` Bart Schaefer
2015-01-28  3:21           ` Tomoki Sekiyama
2015-01-28 18:41             ` Bart Schaefer
2016-11-11 16:58           ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=150125122410.ZM31619@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=tomoki.sekiyama@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).