Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Final demise of alias stack
- X-seq: zsh-workers 2558
- From: Peter Stephenson <pws@xxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: Re: Final demise of alias stack
- Date: Wed, 11 Dec 1996 16:52:10 +0100
- In-reply-to: "Peter Stephenson"'s message of "Wed, 11 Dec 1996 09:20:58 MET." <199612110820.JAA15929@xxxxxxxxxx>
I wrote:
> % alias foo='echo foo1 '
> % alias bar=foo
> % alias rod=bar
> % foo rod
> foo1 bar
>
> the foo forces rod to be expanded, but only as far as bar; the bar does
> not get expanded to foo.
If this really is a bug, this is the fix (i.e. you get 'foo1 echo
foo1' at the end and a second argument would also be eligible for
alias substitution).
The thing to do is to keep the more-alias status separate from the
input buffer, consequently it seemed neater to have a separate status
variable again (in fact, that's really the only alteration).
*** Src/globals.h.alm Wed Dec 11 16:35:55 1996
--- Src/globals.h Wed Dec 11 16:36:54 1996
***************
*** 204,209 ****
--- 204,213 ----
EXTERN int inbufflags;
+ /* flag that an alias should be expanded after expansion ending in space */
+
+ EXTERN int inalmore;
+
/* != 0 if this is a subshell */
EXTERN int subsh;
*** Src/input.c.alm Wed Dec 11 09:36:15 1996
--- Src/input.c Wed Dec 11 16:40:02 1996
***************
*** 58,67 ****
* inpop(), which effectively flushes any unread input as well as restoring
* the previous input state.
*
! * The flags INP_ALMORE is set when a popped alias ends in a space so that
! * the next word should also be alias expanded. The flag is reset in
! * exalias(). The internal flag INP_ALCONT shows that the stack element
! * was pushed by an alias expansion and should not be needed elsewhere.
*
* PWS 1996/12/10
*/
--- 58,70 ----
* inpop(), which effectively flushes any unread input as well as restoring
* the previous input state.
*
! * The internal flag INP_ALCONT shows that the stack element was pushed
! * by an alias expansion; it should not be needed elsewhere.
! *
! * The global variable inalmore is set to indicate aliases should
! * continue to be expanded because the last alias expansion ended
! * in a space. It is only reset after a complete word was read
! * without expanding a new alias, in exalias().
*
* PWS 1996/12/10
*/
***************
*** 420,426 ****
instacktop->bufptr = inbufptr;
instacktop->bufleft = inbufleft;
instacktop->bufct = inbufct;
! inbufflags &= ~(INP_ALCONT|INP_ALMORE);
if (flags & (INP_ALIAS|INP_HIST)) {
/*
* Text is expansion for history or alias, so continue
--- 423,429 ----
instacktop->bufptr = inbufptr;
instacktop->bufleft = inbufleft;
instacktop->bufct = inbufct;
! inbufflags &= ~INP_ALCONT;
if (flags & (INP_ALIAS|INP_HIST)) {
/*
* Text is expansion for history or alias, so continue
***************
*** 486,492 ****
/* a real alias: mark it as unused. */
instacktop->alias->inuse = 0;
if (*t && t[strlen(t) - 1] == ' ') {
! inbufflags |= INP_ALMORE;
histbackword();
}
}
--- 489,495 ----
/* a real alias: mark it as unused. */
instacktop->alias->inuse = 0;
if (*t && t[strlen(t) - 1] == ' ') {
! inalmore = 1;
histbackword();
}
}
*** Src/lex.c.alm Wed Dec 11 16:40:16 1996
--- Src/lex.c Wed Dec 11 16:40:35 1996
***************
*** 1258,1264 ****
/* Check for an alias */
an = noaliases ? NULL : (Alias) aliastab->getnode(aliastab, yytext);
if (an && !an->inuse && ((an->flags & ALIAS_GLOBAL) || incmdpos ||
! (inbufflags & INP_ALMORE))) {
inpush(an->text, INP_ALIAS, an);
/* remove from history if it begins with space */
if (isset(HISTIGNORESPACE) && an->text[0] == ' ')
--- 1258,1264 ----
/* Check for an alias */
an = noaliases ? NULL : (Alias) aliastab->getnode(aliastab, yytext);
if (an && !an->inuse && ((an->flags & ALIAS_GLOBAL) || incmdpos ||
! inalmore)) {
inpush(an->text, INP_ALIAS, an);
/* remove from history if it begins with space */
if (isset(HISTIGNORESPACE) && an->text[0] == ' ')
***************
*** 1279,1285 ****
} else if (incond && yytext[0] == '!' && !yytext[1])
tok = BANG;
}
! inbufflags &= ~INP_ALMORE;
return 0;
}
--- 1279,1285 ----
} else if (incond && yytext[0] == '!' && !yytext[1])
tok = BANG;
}
! inalmore = 0;
return 0;
}
*** Src/zsh.h.alm Wed Dec 11 16:35:49 1996
--- Src/zsh.h Wed Dec 11 16:37:06 1996
***************
*** 197,204 ****
#define INP_ALIAS (1<<1) /* expanding alias or history */
#define INP_HIST (1<<2) /* expanding history */
#define INP_CONT (1<<3) /* continue onto previously stacked input */
! #define INP_ALMORE (1<<4) /* alias ended with space, continue expn. */
! #define INP_ALCONT (1<<5) /* stack is continued from alias expn. */
/* Flags for metafy */
#define META_REALLOC 0
--- 197,203 ----
#define INP_ALIAS (1<<1) /* expanding alias or history */
#define INP_HIST (1<<2) /* expanding history */
#define INP_CONT (1<<3) /* continue onto previously stacked input */
! #define INP_ALCONT (1<<4) /* stack is continued from alias expn. */
/* Flags for metafy */
#define META_REALLOC 0
--
Peter Stephenson <pws@xxxxxx> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author