sysctl: fix up some option processing
A patch from Debian. Backported-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
db4751c216
commit
ff211c2f2e
12
sysctl.c
12
sysctl.c
@ -464,6 +464,7 @@ int main(int argc, char *argv[]) {
|
|||||||
const char *me = (const char *)basename(argv[0]);
|
const char *me = (const char *)basename(argv[0]);
|
||||||
bool SwitchesAllowed = true;
|
bool SwitchesAllowed = true;
|
||||||
bool WriteMode = false;
|
bool WriteMode = false;
|
||||||
|
bool DisplayAllOpt = false;
|
||||||
int ReturnCode = 0;
|
int ReturnCode = 0;
|
||||||
const char *preloadfile = DEFAULT_PRELOAD;
|
const char *preloadfile = DEFAULT_PRELOAD;
|
||||||
|
|
||||||
@ -529,8 +530,8 @@ int main(int argc, char *argv[]) {
|
|||||||
case 'a': // string and integer values (for Linux, all of them)
|
case 'a': // string and integer values (for Linux, all of them)
|
||||||
case 'A': // same as -a -o
|
case 'A': // same as -a -o
|
||||||
case 'X': // same as -a -x
|
case 'X': // same as -a -x
|
||||||
SwitchesAllowed = false;
|
DisplayAllOpt = true;
|
||||||
return DisplayAll(PROC_PATH);
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
fprintf(stdout, "sysctl (%s)\n",procps_version);
|
fprintf(stdout, "sysctl (%s)\n",procps_version);
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -545,6 +546,8 @@ int main(int argc, char *argv[]) {
|
|||||||
} else {
|
} else {
|
||||||
if (NameOnly && Quiet) // nonsense
|
if (NameOnly && Quiet) // nonsense
|
||||||
return Usage(me);
|
return Usage(me);
|
||||||
|
if (DisplayAllOpt) // We cannot have values with -a
|
||||||
|
return Usage(me);
|
||||||
SwitchesAllowed = false;
|
SwitchesAllowed = false;
|
||||||
if (WriteMode || strchr(*argv, '='))
|
if (WriteMode || strchr(*argv, '='))
|
||||||
ReturnCode = WriteSetting(*argv);
|
ReturnCode = WriteSetting(*argv);
|
||||||
@ -552,6 +555,11 @@ int main(int argc, char *argv[]) {
|
|||||||
ReturnCode = ReadSetting(*argv);
|
ReturnCode = ReadSetting(*argv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (DisplayAllOpt) {
|
||||||
|
if (Quiet)
|
||||||
|
return Usage(me);
|
||||||
|
return DisplayAll(PROC_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
return ReturnCode;
|
return ReturnCode;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user