* Re: Global aliases, eval, and completion (Re: Expanding interactively aliases)
@ 2001-02-26 9:42 Sven Wischnowsky
0 siblings, 0 replies; 11+ messages in thread
From: Sven Wischnowsky @ 2001-02-26 9:42 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> ...
>
> Having already implemented `autoload -U', we could now easily add a zsh
> option `noalias' akin to `noglob', and then add that to $_comp_options.
> Then completion functions that specifically wanted aliases could restore
> the `alias' option in the scope where they wanted it.
Hmhm, I was thinking about something similar...
> Which incidentally leads me to wonder if bufferwords() doesn't have a
> potential bug in that it forces the C variable `noaliases' to 1 and 0
> without saving/restoring it? I suppose as currently used `noaliases'
> can't possibly be anything other than 0 during bufferwords() ...
Better make sure... (thanks for finding it).
Bye
Sven
Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.22
diff -u -r1.22 hist.c
--- Src/hist.c 2001/02/19 10:26:54 1.22
+++ Src/hist.c 2001/02/26 09:41:32
@@ -2151,6 +2151,7 @@
{
int num = 0, cur = -1, got = 0, ne = noerrs, ocs = cs, oll = ll;
int owb = wb, owe = we, oadx = addedx, ozp = zleparse, onc = nocomments;
+ int ona = noaliases;
char *p;
if (!list)
@@ -2226,7 +2227,7 @@
}
if (cur < 0 && num)
cur = num - 1;
- noaliases = 0;
+ noaliases = ona;
strinend();
inpop();
errflag = 0;
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Global aliases, eval, and completion (Re: Expanding interactively aliases)
@ 2001-03-05 13:28 Sven Wischnowsky
0 siblings, 0 replies; 11+ messages in thread
From: Sven Wischnowsky @ 2001-03-05 13:28 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> ...
>
> We can replace all `eval's of that particular form with
>
> set -A ws ${=~action[2,-2]}
> or
> set -A action ${=~action}
>
> etc., which also gives us liberty to remove the wordsplitting or globbing
> when appropriate (I think wordsplitting always is, but globbing might better
> be left off in a few cases).
I've looked and looked and tried to remember, but... does anyone
remember why we didn't change several of the eval's to the above? Oh,
I mean apart from being too lazy...
Should we still change them? May be a bit faster, but with the
noaliases option... hm, this looks so tedious ;-)
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Global aliases, eval, and completion (Re: Expanding interactively aliases)
@ 2001-02-28 9:10 Sven Wischnowsky
0 siblings, 0 replies; 11+ messages in thread
From: Sven Wischnowsky @ 2001-02-28 9:10 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> On Feb 27, 11:11am, Sven Wischnowsky wrote:
> } Subject: Re: Global aliases, eval, and completion (Re: Expanding interacti
> }
> } Hmhm. Haven't looked through the completion functions yet, but below
> } is a patch to replace the (internal) `noaliases' with an option `ALIAS'.
> } Should I commit that?
>
> I'd have left the internal `noaliases' as it was, and then tested the
> option in these two places:
Yes, I was torn in two, thinking that it might be useful somehow (no,
I don't know either...).
So, the patch below uses the option only in this place:
> } @@ -1556,8 +1551,8 @@
> }
> } if (tok == STRING) {
> } /* Check for an alias */
> } - an = noaliases ? NULL :
> } - (Alias) aliastab->getnode(aliastab, yytext);
> } + an = opts[ALIASOPT] ?
> } + (Alias) aliastab->getnode(aliastab, yytext) : NULL;
> } if (an && !an->inuse && ((an->flags & ALIAS_GLOBAL) || incmdpos ||
> } inalmore)) {
> } inpush(an->text, INP_ALIAS, an);
but not here: (no need to use it here if we look it up at the only
place where aliases are expanded, which is the only place where
noaliases is used)
> } @@ -976,7 +977,7 @@
> }
> } /* This global flag is used to signal the lexer code if it should *
> } * expand aliases or not. */
> } - noaliases = isset(COMPLETEALIASES);
> } + opts[ALIASOPT] = !isset(COMPLETEALIASES);
> }
> } /* Find out if we are somewhere in a `string', i.e. inside '...', *
> } * "...", `...`, or ((...)). Nowadays this is only used to find *
The other hunks make noaliases be reset to its previous value in
several places just to be on the save side...
> } Should it (in options.c) use (OPT_ALL & ~OPT_SH) instead of OPT_ALL?
>
> Turning off aliases when emulating sh sounds like the right thing to me.
No decision here, yet.
I've also renamed the option to `aliases'. I was tempted to do that
yesterday but didn't know which one would sound better to English
speaking folks (esp. after Bart suggested `noalias' in 13529).
And this time I'm going to commit this.
Bye
Sven
Index: Completion/Core/compinit
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/compinit,v
retrieving revision 1.16
diff -u -r1.16 compinit
--- Completion/Core/compinit 2001/02/16 14:57:50 1.16
+++ Completion/Core/compinit 2001/02/28 09:01:11
@@ -137,6 +137,7 @@
NO_ksharrays
NO_cshnullglob
NO_allexport
+ NO_aliases
)
# These can hold names of functions that are to be called before/after all
Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.13
diff -u -r1.13 options.yo
--- Doc/Zsh/options.yo 2001/02/14 17:58:13 1.13
+++ Doc/Zsh/options.yo 2001/02/28 09:01:12
@@ -53,6 +53,11 @@
are changed from the default.
startitem()
+pindex(ALIASES)
+cindex(aliases, expansion)
+item(tt(ALIASES) <D>)(
+Expand aliases.
+)
pindex(ALL_EXPORT)
cindex(export, automatic)
item(tt(ALL_EXPORT) (tt(-a), ksh: tt(-a)))(
Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.14
diff -u -r1.14 lex.c
--- Src/lex.c 2000/12/05 10:34:23 1.14
+++ Src/lex.c 2001/02/28 09:01:12
@@ -1556,7 +1556,7 @@
if (tok == STRING) {
/* Check for an alias */
- an = noaliases ? NULL :
+ an = (noaliases || unset(ALIASESOPT)) ? NULL :
(Alias) aliastab->getnode(aliastab, yytext);
if (an && !an->inuse && ((an->flags & ALIAS_GLOBAL) || incmdpos ||
inalmore)) {
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.6
diff -u -r1.6 options.c
--- Src/options.c 2000/08/10 16:19:12 1.6
+++ Src/options.c 2001/02/28 09:01:13
@@ -69,6 +69,7 @@
* to avoid formatting problems.
*/
static struct optname optns[] = {
+{NULL, "aliases", OPT_EMULATE|OPT_ALL, ALIASESOPT},
{NULL, "allexport", OPT_EMULATE, ALLEXPORT},
{NULL, "alwayslastprompt", OPT_ALL, ALWAYSLASTPROMPT},
{NULL, "alwaystoend", 0, ALWAYSTOEND},
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.24
diff -u -r1.24 zsh.h
--- Src/zsh.h 2000/12/05 10:34:23 1.24
+++ Src/zsh.h 2001/02/28 09:01:13
@@ -1305,6 +1305,7 @@
enum {
OPT_INVALID,
+ ALIASESOPT,
ALLEXPORT,
ALWAYSLASTPROMPT,
ALWAYSTOEND,
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.44
diff -u -r1.44 compcore.c
--- Src/Zle/compcore.c 2001/01/18 14:41:40 1.44
+++ Src/Zle/compcore.c 2001/02/28 09:01:14
@@ -1237,7 +1237,7 @@
LinkNode n;
int owe = we, owb = wb, ocs = cs, swb, swe, scs, soffs, ne = noerrs;
int tl, got = 0, i = 0, cur = -1, oll = ll, sl, remq;
- int ois = instring, oib = inbackt, noffs = lp;
+ int ois = instring, oib = inbackt, noffs = lp, ona = noaliases;
char *tmp, *p, *ns, *ol = (char *) line, sav, *qp, *qs, *ts, qc = '\0';
s += lip;
@@ -1299,7 +1299,7 @@
}
i++;
} while (tok != ENDINPUT && tok != LEXERR);
- noaliases = 0;
+ noaliases = ona;
strinend();
inpop();
errflag = zleparse = 0;
Index: Src/Zle/compctl.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compctl.c,v
retrieving revision 1.9
diff -u -r1.9 compctl.c
--- Src/Zle/compctl.c 2001/01/18 14:41:40 1.9
+++ Src/Zle/compctl.c 2001/02/28 09:01:15
@@ -2753,7 +2753,7 @@
LinkNode n;
int owe = we, owb = wb, ocs = cs, swb, swe, scs, soffs, ne = noerrs;
int sl = strlen(ss), tl, got = 0, i = 0, cur = -1, oll = ll, remq;
- int ois = instring, oib = inbackt;
+ int ois = instring, oib = inbackt, ona = noaliases;
char *tmp, *p, *ns, *ol = (char *) line, sav, *oaq = autoq, *qp, *qs;
char *ts, qc = '\0';
@@ -2813,7 +2813,7 @@
}
i++;
} while (tok != ENDINPUT && tok != LEXERR);
- noaliases = 0;
+ noaliases = ona;
strinend();
inpop();
errflag = zleparse = 0;
@@ -3648,6 +3648,7 @@
LinkList foo = newlinklist();
LinkNode n;
int first = 1, ng = opts[NULLGLOB], oowe = we, oowb = wb;
+ int ona = noaliases;
char *tmpbuf;
opts[NULLGLOB] = 1;
@@ -3669,7 +3670,7 @@
addlinknode(foo, ztrdup(tokstr));
first = 0;
} while (tok != ENDINPUT && tok != LEXERR);
- noaliases = 0;
+ noaliases = ona;
strinend();
inpop();
errflag = zleparse = 0;
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.23
diff -u -r1.23 zle_tricky.c
--- Src/Zle/zle_tricky.c 2001/01/18 14:41:40 1.23
+++ Src/Zle/zle_tricky.c 2001/02/28 09:01:16
@@ -964,6 +964,7 @@
get_comp_string(void)
{
int t0, tt0, i, j, k, cp, rd, sl, ocs, ins, oins, ia, parct, varq = 0;
+ int ona = noaliases;
char *s = NULL, *linptr, *tmp, *p, *tt = NULL;
freebrinfo(brbeg);
@@ -1236,12 +1237,12 @@
addedx = 0;
goto start;
}
- noaliases = 0;
+ noaliases = ona;
lexrestore();
return NULL;
}
- noaliases = 0;
+ noaliases = ona;
/* Check if we are in an array subscript. We simply assume that *
* we are in a subscript if we are in brackets. Correct solution *
@@ -2138,7 +2139,7 @@
doexpandhist(void)
{
unsigned char *ol;
- int oll, ocs, ne = noerrs, err;
+ int oll, ocs, ne = noerrs, err, ona = noaliases;
pushheap();
metafy_line();
@@ -2165,7 +2166,7 @@
* means that the expanded string is unusable. */
err = errflag;
noerrs = ne;
- noaliases = 0;
+ noaliases = ona;
strinend();
inpop();
zleparse = 0;
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Global aliases, eval, and completion (Re: Expanding interactively aliases)
2001-02-27 17:49 ` Andrej Borsenkow
@ 2001-02-27 18:25 ` Bart Schaefer
0 siblings, 0 replies; 11+ messages in thread
From: Bart Schaefer @ 2001-02-27 18:25 UTC (permalink / raw)
To: zsh-workers
On Feb 27, 8:49pm, Andrej Borsenkow wrote:
}
} > Turning off aliases when emulating sh sounds like the right thing to me.
}
} Why? POSIX shell defines aliases (but not global aliases IIRC).
Oh, I'd forgotten about that. I still think in terms of emulating the
pre-POSIX Bourne sh. As long as we're consistent about which one it is
that we emulate, either way is fine with me.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: Global aliases, eval, and completion (Re: Expanding interactively aliases)
2001-02-27 16:51 ` Bart Schaefer
2001-02-27 17:42 ` Bart Schaefer
@ 2001-02-27 17:49 ` Andrej Borsenkow
2001-02-27 18:25 ` Bart Schaefer
1 sibling, 1 reply; 11+ messages in thread
From: Andrej Borsenkow @ 2001-02-27 17:49 UTC (permalink / raw)
To: zsh-workers
>
> } Should it (in options.c) use (OPT_ALL & ~OPT_SH) instead of OPT_ALL?
>
> Turning off aliases when emulating sh sounds like the right thing to me.
>
Why? POSIX shell defines aliases (but not global aliases IIRC).
-andrej
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Global aliases, eval, and completion (Re: Expanding interactively aliases)
2001-02-27 16:51 ` Bart Schaefer
@ 2001-02-27 17:42 ` Bart Schaefer
2001-02-27 17:49 ` Andrej Borsenkow
1 sibling, 0 replies; 11+ messages in thread
From: Bart Schaefer @ 2001-02-27 17:42 UTC (permalink / raw)
To: zsh-workers
On Feb 27, 4:51pm, Bart Schaefer wrote:
}
} Turning off aliases when emulating sh sounds like the right thing to me.
Other thoughts:
We're probably approaching the point where we could have a bash emulation
mode too; so far, that would be sh emulation but with aliases turned on,
but there are a few other options (such as `globdots' and `promptsubst')
that could be left unchanged when `emulate bash' is used (as opposed to
being turned off as they are when `emulate sh' is used). I'm not sure
exactly what's the right thing to do with such bash options, though.
Maybe the option should be called `aliases' rather than just `alias'?
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Global aliases, eval, and completion (Re: Expanding interactively aliases)
2001-02-27 10:11 Sven Wischnowsky
@ 2001-02-27 16:51 ` Bart Schaefer
2001-02-27 17:42 ` Bart Schaefer
2001-02-27 17:49 ` Andrej Borsenkow
0 siblings, 2 replies; 11+ messages in thread
From: Bart Schaefer @ 2001-02-27 16:51 UTC (permalink / raw)
To: zsh-workers
On Feb 27, 11:11am, Sven Wischnowsky wrote:
} Subject: Re: Global aliases, eval, and completion (Re: Expanding interacti
}
} Hmhm. Haven't looked through the completion functions yet, but below
} is a patch to replace the (internal) `noaliases' with an option `ALIAS'.
} Should I commit that?
I'd have left the internal `noaliases' as it was, and then tested the
option in these two places:
} @@ -1556,8 +1551,8 @@
}
} if (tok == STRING) {
} /* Check for an alias */
} - an = noaliases ? NULL :
} - (Alias) aliastab->getnode(aliastab, yytext);
} + an = opts[ALIASOPT] ?
} + (Alias) aliastab->getnode(aliastab, yytext) : NULL;
} if (an && !an->inuse && ((an->flags & ALIAS_GLOBAL) || incmdpos ||
} inalmore)) {
} inpush(an->text, INP_ALIAS, an);
} @@ -976,7 +977,7 @@
}
} /* This global flag is used to signal the lexer code if it should *
} * expand aliases or not. */
} - noaliases = isset(COMPLETEALIASES);
} + opts[ALIASOPT] = !isset(COMPLETEALIASES);
}
} /* Find out if we are somewhere in a `string', i.e. inside '...', *
} * "...", `...`, or ((...)). Nowadays this is only used to find *
There's no reason to flip the sense of the option when the code internally
wants to disable aliases, nor as far as I can tell any reason to allow the
option to be enabled by user code when the internals have disabled it.
} Should it (in options.c) use (OPT_ALL & ~OPT_SH) instead of OPT_ALL?
Turning off aliases when emulating sh sounds like the right thing to me.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Global aliases, eval, and completion (Re: Expanding interactively aliases)
@ 2001-02-27 10:11 Sven Wischnowsky
2001-02-27 16:51 ` Bart Schaefer
0 siblings, 1 reply; 11+ messages in thread
From: Sven Wischnowsky @ 2001-02-27 10:11 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> I was just diffing some backup copies I'd made of things like minor changes
> to _arguments against the current sources, and I found the solution I think
> you're thinking about.
>
> } [...] _arguments does things like
> }
> } eval ws\=\( "${action[2,-2]}" \)
> } and
> } eval "action=( $action )"
> }
> } There are a number of other completion functions that use eval for similar
> } purposes.
>
> We can replace all `eval's of that particular form with
>
> set -A ws ${=~action[2,-2]}
> or
> set -A action ${=~action}
Ah, yes, that's what I wanted to remember...
> etc., which also gives us liberty to remove the wordsplitting or globbing
> when appropriate (I think wordsplitting always is, but globbing might better
> be left off in a few cases).
Hmhm. Haven't looked through the completion functions yet, but below
is a patch to replace the (internal) `noaliases' with an option `ALIAS'.
Should I commit that? Should it (in options.c) use (OPT_ALL & ~OPT_SH)
instead of OPT_ALL?
Bye
Sven
Index: Completion/Core/compinit
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/compinit,v
retrieving revision 1.16
diff -u -r1.16 compinit
--- Completion/Core/compinit 2001/02/16 14:57:50 1.16
+++ Completion/Core/compinit 2001/02/27 10:05:37
@@ -137,6 +137,7 @@
NO_ksharrays
NO_cshnullglob
NO_allexport
+ NO_alias
)
# These can hold names of functions that are to be called before/after all
Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.13
diff -u -r1.13 options.yo
--- Doc/Zsh/options.yo 2001/02/14 17:58:13 1.13
+++ Doc/Zsh/options.yo 2001/02/27 10:05:39
@@ -53,6 +53,11 @@
are changed from the default.
startitem()
+pindex(ALIAS)
+cindex(alias, expansion)
+item(tt(ALIAS) <D>)(
+Expand aliases.
+)
pindex(ALL_EXPORT)
cindex(export, automatic)
item(tt(ALL_EXPORT) (tt(-a), ksh: tt(-a)))(
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.24
diff -u -r1.24 exec.c
--- Src/exec.c 2001/01/16 13:44:20 1.24
+++ Src/exec.c 2001/02/27 10:05:41
@@ -3224,14 +3224,14 @@
Shfunc
loadautofn(Shfunc shf, int fksh, int autol)
{
- int noalias = noaliases, ksh = 1;
+ int noalias = opts[ALIASOPT], ksh = 1;
Eprog prog;
pushheap();
- noaliases = (shf->flags & PM_UNALIASED);
+ opts[ALIASOPT] = !(shf->flags & PM_UNALIASED);
prog = getfpfunc(shf->nam, &ksh);
- noaliases = noalias;
+ opts[ALIASOPT] = noalias;
if (ksh == 1)
ksh = fksh;
Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.23
diff -u -r1.23 hist.c
--- Src/hist.c 2001/02/26 09:43:08 1.23
+++ Src/hist.c 2001/02/27 10:05:42
@@ -2151,7 +2151,7 @@
{
int num = 0, cur = -1, got = 0, ne = noerrs, ocs = cs, oll = ll;
int owb = wb, owe = we, oadx = addedx, ozp = zleparse, onc = nocomments;
- int ona = noaliases;
+ int ona = opts[ALIASOPT];
char *p;
if (!list)
@@ -2190,7 +2190,7 @@
if (cs)
cs--;
strinbeg(0);
- noaliases = 1;
+ opts[ALIASOPT] = 0;
do {
if (incond)
incond = 1 + (tok != DINBRACK && tok != INPAR &&
@@ -2227,7 +2227,7 @@
}
if (cur < 0 && num)
cur = num - 1;
- noaliases = ona;
+ opts[ALIASOPT] = ona;
strinend();
inpop();
errflag = 0;
Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.14
diff -u -r1.14 lex.c
--- Src/lex.c 2000/12/05 10:34:23 1.14
+++ Src/lex.c 2001/02/27 10:05:42
@@ -98,11 +98,6 @@
/**/
mod_export int wb, we;
-/* 1 if aliases should not be expanded */
-
-/**/
-mod_export int noaliases;
-
/* we are parsing a line sent to use by the editor */
/**/
@@ -1556,8 +1551,8 @@
if (tok == STRING) {
/* Check for an alias */
- an = noaliases ? NULL :
- (Alias) aliastab->getnode(aliastab, yytext);
+ an = opts[ALIASOPT] ?
+ (Alias) aliastab->getnode(aliastab, yytext) : NULL;
if (an && !an->inuse && ((an->flags & ALIAS_GLOBAL) || incmdpos ||
inalmore)) {
inpush(an->text, INP_ALIAS, an);
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.6
diff -u -r1.6 options.c
--- Src/options.c 2000/08/10 16:19:12 1.6
+++ Src/options.c 2001/02/27 10:05:42
@@ -69,6 +69,7 @@
* to avoid formatting problems.
*/
static struct optname optns[] = {
+{NULL, "alias", OPT_EMULATE|OPT_ALL, ALIASOPT},
{NULL, "allexport", OPT_EMULATE, ALLEXPORT},
{NULL, "alwayslastprompt", OPT_ALL, ALWAYSLASTPROMPT},
{NULL, "alwaystoend", 0, ALWAYSTOEND},
Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.17
diff -u -r1.17 parse.c
--- Src/parse.c 2001/01/22 12:03:55 1.17
+++ Src/parse.c 2001/02/27 10:05:44
@@ -2523,7 +2523,7 @@
static int
build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
{
- int dfd, fd, hlen, tlen, flen, ona = noaliases;
+ int dfd, fd, hlen, tlen, flen, ona = opts[ALIASOPT];
LinkList progs;
char *file;
Eprog prog;
@@ -2537,7 +2537,7 @@
return 1;
}
progs = newlinklist();
- noaliases = ali;
+ opts[ALIASOPT] = !ali;
for (hlen = FD_PRELEN, tlen = 0; *files; files++) {
if (!strcmp(*files, "-k")) {
@@ -2553,7 +2553,7 @@
close(fd);
close(dfd);
zwarnnam(nam, "can't open file: %s", *files, 0);
- noaliases = ona;
+ opts[ALIASOPT] = ona;
unlink(dump);
return 1;
}
@@ -2565,7 +2565,7 @@
close(dfd);
zfree(file, flen);
zwarnnam(nam, "can't read file: %s", *files, 0);
- noaliases = ona;
+ opts[ALIASOPT] = ona;
unlink(dump);
return 1;
}
@@ -2577,7 +2577,7 @@
close(dfd);
zfree(file, flen);
zwarnnam(nam, "can't read file: %s", *files, 0);
- noaliases = ona;
+ opts[ALIASOPT] = ona;
unlink(dump);
return 1;
}
@@ -2595,7 +2595,7 @@
tlen += (prog->len - (prog->npats * sizeof(Patprog)) +
sizeof(wordcode) - 1) / sizeof(wordcode);
}
- noaliases = ona;
+ opts[ALIASOPT] = ona;
tlen = (tlen + hlen) * sizeof(wordcode);
@@ -2614,21 +2614,21 @@
WCFunc wcf;
if (shf->flags & PM_UNDEFINED) {
- int ona = noaliases;
+ int ona = opts[ALIASOPT];
if (!(what & 2)) {
zwarnnam(nam, "function is not loaded: %s", shf->nam, 0);
return 1;
}
- noaliases = (shf->flags & PM_UNALIASED);
+ opts[ALIASOPT] = !(shf->flags & PM_UNALIASED);
if (!(prog = getfpfunc(shf->nam, NULL)) || prog == &dummy_eprog) {
- noaliases = ona;
+ opts[ALIASOPT] = ona;
zwarnnam(nam, "can't load function: %s", shf->nam, 0);
return 1;
}
if (prog->dump)
prog = dupeprog(prog, 1);
- noaliases = ona;
+ opts[ALIASOPT] = ona;
} else {
if (!(what & 1)) {
zwarnnam(nam, "function is already loaded: %s", shf->nam, 0);
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.24
diff -u -r1.24 zsh.h
--- Src/zsh.h 2000/12/05 10:34:23 1.24
+++ Src/zsh.h 2001/02/27 10:05:45
@@ -1305,6 +1305,7 @@
enum {
OPT_INVALID,
+ ALIASOPT,
ALLEXPORT,
ALWAYSLASTPROMPT,
ALWAYSTOEND,
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.44
diff -u -r1.44 compcore.c
--- Src/Zle/compcore.c 2001/01/18 14:41:40 1.44
+++ Src/Zle/compcore.c 2001/02/27 10:05:46
@@ -1237,7 +1237,7 @@
LinkNode n;
int owe = we, owb = wb, ocs = cs, swb, swe, scs, soffs, ne = noerrs;
int tl, got = 0, i = 0, cur = -1, oll = ll, sl, remq;
- int ois = instring, oib = inbackt, noffs = lp;
+ int ois = instring, oib = inbackt, noffs = lp, ona = opts[ALIASOPT];
char *tmp, *p, *ns, *ol = (char *) line, sav, *qp, *qs, *ts, qc = '\0';
s += lip;
@@ -1264,7 +1264,7 @@
line = (unsigned char *) tmp;
ll = tl - 1;
strinbeg(0);
- noaliases = 1;
+ opts[ALIASOPT] = 0;
do {
ctxtlex();
if (tok == LEXERR) {
@@ -1299,7 +1299,7 @@
}
i++;
} while (tok != ENDINPUT && tok != LEXERR);
- noaliases = 0;
+ opts[ALIASOPT] = ona;
strinend();
inpop();
errflag = zleparse = 0;
Index: Src/Zle/compctl.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compctl.c,v
retrieving revision 1.9
diff -u -r1.9 compctl.c
--- Src/Zle/compctl.c 2001/01/18 14:41:40 1.9
+++ Src/Zle/compctl.c 2001/02/27 10:05:48
@@ -2753,7 +2753,7 @@
LinkNode n;
int owe = we, owb = wb, ocs = cs, swb, swe, scs, soffs, ne = noerrs;
int sl = strlen(ss), tl, got = 0, i = 0, cur = -1, oll = ll, remq;
- int ois = instring, oib = inbackt;
+ int ois = instring, oib = inbackt, ona = opts[ALIASOPT];
char *tmp, *p, *ns, *ol = (char *) line, sav, *oaq = autoq, *qp, *qs;
char *ts, qc = '\0';
@@ -2778,7 +2778,7 @@
line = (unsigned char *) tmp;
ll = tl - 1;
strinbeg(0);
- noaliases = 1;
+ opts[ALIASOPT] = 0;
do {
ctxtlex();
if (tok == LEXERR) {
@@ -2813,7 +2813,7 @@
}
i++;
} while (tok != ENDINPUT && tok != LEXERR);
- noaliases = 0;
+ opts[ALIASOPT] = ona;
strinend();
inpop();
errflag = zleparse = 0;
@@ -3648,6 +3648,7 @@
LinkList foo = newlinklist();
LinkNode n;
int first = 1, ng = opts[NULLGLOB], oowe = we, oowb = wb;
+ int ona = opts[ALIASOPT];
char *tmpbuf;
opts[NULLGLOB] = 1;
@@ -3660,7 +3661,7 @@
sprintf(tmpbuf, "foo %s", cc->str); /* KLUDGE! */
inpush(tmpbuf, 0, NULL);
strinbeg(0);
- noaliases = 1;
+ opts[ALIASOPT] = 0;
do {
ctxtlex();
if (tok == ENDINPUT || tok == LEXERR)
@@ -3669,7 +3670,7 @@
addlinknode(foo, ztrdup(tokstr));
first = 0;
} while (tok != ENDINPUT && tok != LEXERR);
- noaliases = 0;
+ opts[ALIASOPT] = ona;
strinend();
inpop();
errflag = zleparse = 0;
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.23
diff -u -r1.23 zle_tricky.c
--- Src/Zle/zle_tricky.c 2001/01/18 14:41:40 1.23
+++ Src/Zle/zle_tricky.c 2001/02/27 10:05:49
@@ -964,6 +964,7 @@
get_comp_string(void)
{
int t0, tt0, i, j, k, cp, rd, sl, ocs, ins, oins, ia, parct, varq = 0;
+ int ona = opts[ALIASOPT];
char *s = NULL, *linptr, *tmp, *p, *tt = NULL;
freebrinfo(brbeg);
@@ -976,7 +977,7 @@
/* This global flag is used to signal the lexer code if it should *
* expand aliases or not. */
- noaliases = isset(COMPLETEALIASES);
+ opts[ALIASOPT] = !isset(COMPLETEALIASES);
/* Find out if we are somewhere in a `string', i.e. inside '...', *
* "...", `...`, or ((...)). Nowadays this is only used to find *
@@ -1236,12 +1237,12 @@
addedx = 0;
goto start;
}
- noaliases = 0;
+ opts[ALIASOPT] = ona;
lexrestore();
return NULL;
}
- noaliases = 0;
+ opts[ALIASOPT] = ona;
/* Check if we are in an array subscript. We simply assume that *
* we are in a subscript if we are in brackets. Correct solution *
@@ -2138,7 +2139,7 @@
doexpandhist(void)
{
unsigned char *ol;
- int oll, ocs, ne = noerrs, err;
+ int oll, ocs, ne = noerrs, err, ona = opts[ALIASOPT];
pushheap();
metafy_line();
@@ -2152,7 +2153,7 @@
/* We push ol as it will remain unchanged */
inpush((char *) ol, 0, NULL);
strinbeg(1);
- noaliases = 1;
+ opts[ALIASOPT] = 0;
noerrs = 1;
exlast = inbufct;
do {
@@ -2165,7 +2166,7 @@
* means that the expanded string is unusable. */
err = errflag;
noerrs = ne;
- noaliases = 0;
+ opts[ALIASOPT] = ona;
strinend();
inpop();
zleparse = 0;
@@ -2282,12 +2283,12 @@
int
expandcmdpath(char **args)
{
- int oldcs = cs, na = noaliases;
+ int oldcs = cs, ona = opts[ALIASOPT];
char *s, *str;
- noaliases = 1;
+ opts[ALIASOPT] = 0;
s = getcurcmd();
- noaliases = na;
+ opts[ALIASOPT] = ona;
if (!s || cmdwb < 0 || cmdwe < cmdwb)
return 1;
str = findcmd(s, 1);
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Global aliases, eval, and completion (Re: Expanding interactively aliases)
2001-02-26 7:25 ` Global aliases, eval, and completion (Re: Expanding interactively aliases) Bart Schaefer
2001-02-26 16:51 ` Bart Schaefer
@ 2001-02-26 23:03 ` Oliver Kiddle
1 sibling, 0 replies; 11+ messages in thread
From: Oliver Kiddle @ 2001-02-26 23:03 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
>
> } > Would it be easy to avoid this somehow?
>
> Having already implemented `autoload -U', we could now easily add a zsh
> option `noalias' akin to `noglob', and then add that to $_comp_options.
> Then completion functions that specifically wanted aliases could restore
> the `alias' option in the scope where they wanted it.
That seems like a good idea. The only other thing I can think of is
another precommand modifier - noalias, like noglob.
> I said exactly the same thing about "source -U" in the aforementioned
> year-ago thread.
I remember that actually. I'm undecided on it myself because source -U
would be useful. Incidentally, tcsh has a -h option to source (but no
options to eval). I suppose a noalias option would avoid the need for a
source -U.
Oliver Kiddle
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Global aliases, eval, and completion (Re: Expanding interactively aliases)
2001-02-26 7:25 ` Global aliases, eval, and completion (Re: Expanding interactively aliases) Bart Schaefer
@ 2001-02-26 16:51 ` Bart Schaefer
2001-02-26 23:03 ` Oliver Kiddle
1 sibling, 0 replies; 11+ messages in thread
From: Bart Schaefer @ 2001-02-26 16:51 UTC (permalink / raw)
To: zsh-workers
On Feb 26, 7:25am, Bart Schaefer wrote:
}
} } > My real point is that the existing _expand appears to be expanding
} } > global aliases already. [...] A quick check reveals that this is
} } > with the substitute style and is due to the fact that the aliases
} } > are expanded within eval.
} }
} } Now that you say that... I seem to have a very faint memory of a
} } discussion about this (not in _expand, I think, we had the problem
} } somewhere else). I think we found a solution which I can't think of
} } now and I don't know where to search for it either.
I was just diffing some backup copies I'd made of things like minor changes
to _arguments against the current sources, and I found the solution I think
you're thinking about.
} [...] _arguments does things like
}
} eval ws\=\( "${action[2,-2]}" \)
} and
} eval "action=( $action )"
}
} There are a number of other completion functions that use eval for similar
} purposes.
We can replace all `eval's of that particular form with
set -A ws ${=~action[2,-2]}
or
set -A action ${=~action}
etc., which also gives us liberty to remove the wordsplitting or globbing
when appropriate (I think wordsplitting always is, but globbing might better
be left off in a few cases).
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 11+ messages in thread
* Global aliases, eval, and completion (Re: Expanding interactively aliases)
2001-02-21 8:19 Expanding interactively aliases Sven Wischnowsky
@ 2001-02-26 7:25 ` Bart Schaefer
2001-02-26 16:51 ` Bart Schaefer
2001-02-26 23:03 ` Oliver Kiddle
0 siblings, 2 replies; 11+ messages in thread
From: Bart Schaefer @ 2001-02-26 7:25 UTC (permalink / raw)
To: zsh-workers
On Feb 21, 9:19am, Sven Wischnowsky wrote:
} Subject: Re: Expanding interactively aliases
}
} Oliver Kiddle wrote:
}
} > My real point is that the existing _expand appears to be expanding global
} > aliases already. I wouldn't have expected this because -U is used when
} > autoloading _expand. A quick check reveals that this is with the
} > substitute style and is due to the fact that the aliases are expanded
} > within eval.
}
} Now that you say that... I seem to have a very faint memory of a
} discussion about this (not in _expand, I think, we had the problem
} somewhere else). I think we found a solution which I can't think of
} now and I don't know where to search for it either.
You may be thinking of the thread that led to invention of "autoload -U"
in the first place.
There was another thread last March with the subject "Default fpath" that
made a brief mention of the issue of aliases being expanded by "eval" and
by "source", but that was a very brief sideline of the main topic.
Of course it's entirely reasonable to _want_ aliases expanded by eval:
foo() {
if [[ $1 == --debug ]]
then
shift
alias somecommand='print -u2 somecommand'
fi
# ... possibly much intervening code ...
eval 'somecommand "$@"'
}
Because of the way functions are "compiled", using eval is the only way
to create/use such a conditional alias.
} > I don't think it is ideal that autoload -U functions are subject to
} > aliases within eval and you could probably break a few bits of completion
} > with certain global aliases.
Yeah, particularly because _arguments does things like
eval ws\=\( "${action[2,-2]}" \)
and
eval "action=( $action )"
There are a number of other completion functions that use eval for similar
purposes.
} > Would it be easy to avoid this somehow?
Having already implemented `autoload -U', we could now easily add a zsh
option `noalias' akin to `noglob', and then add that to $_comp_options.
Then completion functions that specifically wanted aliases could restore
the `alias' option in the scope where they wanted it.
Which incidentally leads me to wonder if bufferwords() doesn't have a
potential bug in that it forces the C variable `noaliases' to 1 and 0
without saving/restoring it? I suppose as currently used `noaliases'
can't possibly be anything other than 0 during bufferwords() ...
} > The other solution would be a -U argument to eval which probably isn't
} > a great idea because eval currently takes no options.
I said exactly the same thing about "source -U" in the aforementioned
year-ago thread.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2001-03-05 13:28 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-26 9:42 Global aliases, eval, and completion (Re: Expanding interactively aliases) Sven Wischnowsky
-- strict thread matches above, loose matches on Subject: below --
2001-03-05 13:28 Sven Wischnowsky
2001-02-28 9:10 Sven Wischnowsky
2001-02-27 10:11 Sven Wischnowsky
2001-02-27 16:51 ` Bart Schaefer
2001-02-27 17:42 ` Bart Schaefer
2001-02-27 17:49 ` Andrej Borsenkow
2001-02-27 18:25 ` Bart Schaefer
2001-02-21 8:19 Expanding interactively aliases Sven Wischnowsky
2001-02-26 7:25 ` Global aliases, eval, and completion (Re: Expanding interactively aliases) Bart Schaefer
2001-02-26 16:51 ` Bart Schaefer
2001-02-26 23:03 ` Oliver Kiddle
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).