From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: [PATCH] Re: aliases+=(foo 'echo bar') crash
Date: Wed, 23 Jul 2014 22:45:35 -0700 [thread overview]
Message-ID: <140723224535.ZM17657@torch.brasslantern.com> (raw)
In-Reply-To: <140723200417.ZM5161@torch.brasslantern.com>
On Jul 23, 8:04pm, Bart Schaefer wrote:
}
} The problem may be that the aliases hash has been autoloaded from the
} zsh/parameter module AFTER the flow of control has already passed the
} point of deciding what function to call to perform the assignment, and
} so is using the generic hash function instead of the special functions
} for setting aliases.
It's both better and worse than that. When createparam() is called for
a value that doesn't already exist in the aliases hash table, a new
unset value is correctly created, but then assigngetset() is called on
it, which clobbers the special gsu structure with the default setfn.
I believe the following fixes it for the zsh/parameter module, but there
may be other modules where the same problem arises.
diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index 22148f9..0385a70 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -106,7 +106,7 @@ getpmparameter(UNUSED(HashTable ht), const char *name)
pm->u.str = paramtypestr(rpm);
else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -224,7 +224,7 @@ getpmcommand(UNUSED(HashTable ht), const char *name)
}
} else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -410,7 +410,7 @@ getfunction(UNUSED(HashTable ht), const char *name, int dis)
}
} else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -661,7 +661,7 @@ getbuiltin(UNUSED(HashTable ht), const char *name, int dis)
pm->u.str = dupstring(t);
} else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -876,7 +876,7 @@ getpmoption(UNUSED(HashTable ht), const char *name)
}
else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -934,7 +934,7 @@ getpmmodule(UNUSED(HashTable ht), const char *name)
pm->u.str = dupstring(type);
else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -1048,7 +1048,7 @@ getpmhistory(UNUSED(HashTable ht), const char *name)
pm->u.str = dupstring(he->node.nam);
else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -1158,7 +1158,7 @@ getpmjobtext(UNUSED(HashTable ht), const char *name)
pm->u.str = pmjobtext(job);
else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -1259,7 +1259,7 @@ getpmjobstate(UNUSED(HashTable ht), const char *name)
pm->u.str = pmjobstate(job);
else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -1325,7 +1325,7 @@ getpmjobdir(UNUSED(HashTable ht), const char *name)
pm->u.str = pmjobdir(job);
else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -1451,7 +1451,7 @@ getpmnameddir(UNUSED(HashTable ht), const char *name)
pm->u.str = dupstring(nd->dir);
else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -1502,7 +1502,7 @@ getpmuserdir(UNUSED(HashTable ht), const char *name)
pm->u.str = dupstring(nd->dir);
else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -1754,7 +1754,7 @@ getalias(HashTable alht, UNUSED(HashTable ht), const char *name, int flags)
pm->u.str = dupstring(al->text);
else {
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
}
return &pm->node;
}
@@ -1950,7 +1950,7 @@ getpmusergroups(UNUSED(HashTable ht), const char *name)
if (!gs) {
zerr("failed to retrieve groups for user: %e", errno);
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
return &pm->node;
}
@@ -1965,7 +1965,7 @@ getpmusergroups(UNUSED(HashTable ht), const char *name)
}
pm->u.str = dupstring("");
- pm->node.flags |= PM_UNSET;
+ pm->node.flags |= (PM_UNSET|PM_SPECIAL);
return &pm->node;
}
next prev parent reply other threads:[~2014-07-24 5:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-23 16:09 Stephane Chazelas
2014-07-23 16:52 ` Peter Stephenson
2014-07-24 1:37 ` Bart Schaefer
2014-07-24 3:04 ` Bart Schaefer
2014-07-24 5:45 ` Bart Schaefer [this message]
2014-07-24 9:47 ` [PATCH] " Peter Stephenson
2014-07-24 15:29 ` Bart Schaefer
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=140723224535.ZM17657@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).