Hi,
I have noticed a bug. When running "sysctl ." or "sysctl kern." without
my other patch, I get an extra space between "name" and "in":
sysctl: top level name in . is invalid
It should be:
sysctl: top level name in . is invalid
I also have a patch.
What this patch does is if the top level name is a blank string "", we
do not output anything. Otherwise, we output a space.
The patch is very minor, and may not get accepted (which I understand if
it doesn't).
-Neel
Patch:
Index: sbin/sysctl/sysctl.c
===================================================================
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.259
diff -u -p -u -r1.259 sysctl.c
--- sbin/sysctl/sysctl.c 17 May 2023 22:12:51 -0000 1.259
+++ sbin/sysctl/sysctl.c 29 Aug 2023 21:45:56 -0000
@@ -2957,7 +2957,9 @@ findname(char *string, char *level, char
strcmp(name, namelist->list[i].ctl_name) == 0)
break;
if (i == namelist->size) {
- warnx("%s level name %s in %s is invalid", level, name, string);
+ char sep = strcmp(name, "") == 0 ? '\0' : ' ';
+ warnx("%s level name %s%cin %s is invalid",
+ level, name, sep, string);
return (-1);
}
return (i);