Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Enable further expansion of parameter name by ${!...}



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;



Messages sorted by: Reverse Date, Date, Thread, Author