From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Bug in alias expansion
Date: Sun, 15 Nov 2015 14:26:03 -0800 [thread overview]
Message-ID: <151115142603.ZM20567@torch.brasslantern.com> (raw)
In-Reply-To: <151115135218.ZM25449@torch.brasslantern.com>
On Nov 15, 1:52pm, Bart Schaefer wrote:
}
} So the real question may be, how did we get as far as execsimple()
} without having expanded all the aliases first?
Without being able to answer that ... we can work around the issue by
shoving alias expansion down into parse_string() like so:
diff --git a/Src/exec.c b/Src/exec.c
index c0ee527..b1ca551 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -217,6 +217,11 @@ parse_string(char *s, int reset_lineno)
{
Eprog p;
zlong oldlineno;
+ int noalias = noaliases;
+
+ /* See addvars() */
+ if (noaliases < 0)
+ noaliases = 0;
zcontext_save();
inpush(s, INP_LINENO, NULL);
@@ -231,6 +236,7 @@ parse_string(char *s, int reset_lineno)
strinend();
inpop();
zcontext_restore();
+ noaliases = noalias;
return p;
}
@@ -2249,10 +2255,15 @@ static void
addvars(Estate state, Wordcode pc, int addflags)
{
LinkList vl;
+ int noalias = noaliases;
int xtr, isstr, htok = 0;
char **arr, **ptr, *name;
int flags;
+ /* Signal to parse_string() that it should expand aliases */
+ if (!noaliases)
+ noaliases = -1;
+
Wordcode opc = state->pc;
wordcode ac;
local_list1(svl);
@@ -2291,10 +2302,8 @@ addvars(Estate state, Wordcode pc, int addflags)
if (vl && htok) {
prefork(vl, (isstr ? (PREFORK_SINGLE|PREFORK_ASSIGN) :
PREFORK_ASSIGN), NULL);
- if (errflag) {
- state->pc = opc;
- return;
- }
+ if (errflag)
+ break;
if (!isstr || (isset(GLOBASSIGN) && isstr &&
haswilds((char *)getdata(firstnode(vl))))) {
globlist(vl, 0);
@@ -2305,10 +2314,8 @@ addvars(Estate state, Wordcode pc, int addflags)
if (isset(GLOBASSIGN) && isstr)
unsetparam(name);
}
- if (errflag) {
- state->pc = opc;
- return;
- }
+ if (errflag)
+ break;
}
if (isstr && (empty(vl) || !nextnode(firstnode(vl)))) {
Param pm;
@@ -2331,8 +2338,7 @@ addvars(Estate state, Wordcode pc, int addflags)
(pm->node.flags & PM_RESTRICTED)) {
zerr("%s: restricted", pm->node.nam);
zsfree(val);
- state->pc = opc;
- return;
+ break;
}
if (strcmp(name, "STTY") == 0) {
zsfree(STTYval);
@@ -2346,10 +2352,8 @@ addvars(Estate state, Wordcode pc, int addflags)
opts[ALLEXPORT] = allexp;
} else
pm = assignsparam(name, val, myflags);
- if (errflag) {
- state->pc = opc;
- return;
- }
+ if (errflag)
+ break;
continue;
}
if (vl) {
@@ -2377,6 +2381,7 @@ addvars(Estate state, Wordcode pc, int addflags)
}
}
state->pc = opc;
+ noaliases = noalias;
}
/**/
next prev parent reply other threads:[~2015-11-15 22:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-13 18:03 Kynn Jones
2015-11-14 1:03 ` Bart Schaefer
2015-11-14 18:57 ` Kynn Jones
2015-11-14 19:03 ` Bart Schaefer
2015-11-14 19:19 ` Kynn Jones
2015-11-14 21:40 ` Bart Schaefer
2015-11-14 22:20 ` Kynn Jones
2015-11-15 20:03 ` Peter Stephenson
2015-11-15 21:52 ` Bart Schaefer
2015-11-15 22:26 ` Bart Schaefer [this message]
2015-11-15 22:48 ` Bart Schaefer
2015-11-16 0:50 ` Mikael Magnusson
2015-11-16 3:24 ` Bart Schaefer
2015-11-16 5:42 ` Mikael Magnusson
2015-11-18 10:42 ` Peter Stephenson
2015-11-18 14:13 ` Peter Stephenson
2015-11-18 15:52 ` Bart Schaefer
2015-11-18 16:14 ` Peter Stephenson
2015-11-18 18:09 ` Bart Schaefer
2015-11-17 17:29 ` Peter Stephenson
2015-11-18 4:55 ` Bart Schaefer
2015-11-18 10:30 ` Peter Stephenson
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=151115142603.ZM20567@torch.brasslantern.com \
--to=schaefer@brasslantern.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).