about summary refs log tree commit diff
path: root/Src/lex.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/lex.c')
-rw-r--r--Src/lex.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Src/lex.c b/Src/lex.c
index 494ea8870..1eb0bc7d7 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1740,12 +1740,13 @@ checkalias(void)
 
     if (!noaliases && isset(ALIASESOPT) &&
 	(!isset(POSIXALIASES) ||
-	 !reswdtab->getnode(reswdtab, zshlextext))) {
+	 (tok == STRING && !reswdtab->getnode(reswdtab, zshlextext)))) {
 	char *suf;
 
 	an = (Alias) aliastab->getnode(aliastab, zshlextext);
 	if (an && !an->inuse &&
-	    ((an->node.flags & ALIAS_GLOBAL) || incmdpos || inalmore)) {
+	    ((an->node.flags & ALIAS_GLOBAL) ||
+	     (incmdpos && tok == STRING) || inalmore)) {
 	    inpush(an->text, INP_ALIAS, an);
 	    if (an->text[0] == ' ' && !(an->node.flags & ALIAS_GLOBAL))
 		aliasspaceflag = 1;
@@ -1784,6 +1785,8 @@ exalias(void)
     if (!tokstr) {
 	zshlextext = tokstrings[tok];
 
+	if (tok == NEWLIN)
+	    return 0;
 	return checkalias();
     } else {
 	VARARR(char, copy, (strlen(tokstr) + 1));
@@ -1791,6 +1794,9 @@ exalias(void)
 	if (has_token(tokstr)) {
 	    char *p, *t;
 
+	    if (isset(POSIXALIASES))
+		return 0;
+
 	    zshlextext = p = copy;
 	    for (t = tokstr;
 		 (*p++ = itok(*t) ? ztokens[*t++ - Pound] : *t++););