summaryrefslogtreecommitdiffstats
path: root/bin/ps
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2006-03-08 08:58:44 +0000
committergad <gad@FreeBSD.org>2006-03-08 08:58:44 +0000
commitec3e08db90b8033da09c5f11061c1546308e2c3b (patch)
tree3e30f2e26d73c5f1e49adb336a7fe359518489e9 /bin/ps
parent65255e20ba3e7d2b2183114095a1f69094a020c6 (diff)
downloadFreeBSD-src-ec3e08db90b8033da09c5f11061c1546308e2c3b.zip
FreeBSD-src-ec3e08db90b8033da09c5f11061c1546308e2c3b.tar.gz
Fix the case where the user specifies an alternate heading for some
output-format keyword, and the keyword they picked is an alias to some other keyword. E.g.: ps -o stat=Zustand $$ ('stat' is defined as an alias for 'state') PR: bin/57833 MFC after: 3 weeks
Diffstat (limited to 'bin/ps')
-rw-r--r--bin/ps/keyword.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c
index 564bb31..a80b8ed3 100644
--- a/bin/ps/keyword.c
+++ b/bin/ps/keyword.c
@@ -295,8 +295,9 @@ parsefmt(const char *p, int user)
static VAR *
findvar(char *p, int user, char **header)
{
+ size_t rflen;
VAR *v, key;
- char *hp;
+ char *hp, *realfmt;
hp = strchr(p, '=');
if (hp)
@@ -306,11 +307,17 @@ findvar(char *p, int user, char **header)
v = bsearch(&key, var, sizeof(var)/sizeof(VAR) - 1, sizeof(VAR), vcmp);
if (v && v->alias) {
- if (hp) {
- warnx("%s: illegal keyword specification", p);
- eval = 1;
- }
- parsefmt(v->alias, user);
+ /*
+ * XXX - This processing will not be correct for any alias
+ * which expands into a list of format keywords. Presently
+ * there are no aliases which do that.
+ */
+ rflen = strlen(v->alias) + strlen(hp) + 2;
+ realfmt = malloc(rflen);
+ strlcpy(realfmt, v->alias, rflen);
+ strlcat(realfmt, "=", rflen);
+ strlcat(realfmt, hp, rflen);
+ parsefmt(realfmt, user);
return ((VAR *)NULL);
}
if (!v) {
OpenPOWER on IntegriCloud