Fix getopt a little
This commit is contained in:
parent
2728cef0e1
commit
000f239534
@ -36,7 +36,6 @@ static char **find_mounts (regex_t *node_regex, regex_t *fstype_regex,
|
||||
int nmnts;
|
||||
int i;
|
||||
char **list = NULL;
|
||||
char c;
|
||||
|
||||
if ((nmnts = getmntinfo (&mnts, MNT_NOWAIT)) == 0)
|
||||
eerrorx ("getmntinfo: %s", strerror (errno));
|
||||
@ -155,7 +154,7 @@ int main (int argc, char **argv)
|
||||
{ NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
while ((c = getopt_long (argc, argv, "F:N:S;fnr",
|
||||
while ((c = getopt_long (argc, argv, "F:N:S:fnr",
|
||||
longopts, (int *) 0)) != -1)
|
||||
switch (c) {
|
||||
case 'F':
|
||||
@ -182,7 +181,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
case 'S':
|
||||
if (skip_regex)
|
||||
free (skip_regex);
|
||||
skip_regex = rc_xmalloc (sizeof (regex_t));
|
||||
|
@ -824,13 +824,11 @@ int main (int argc, char **argv)
|
||||
{ "nocolor", 0, NULL, 'C'},
|
||||
{ "nocolour", 0, NULL, 'C'},
|
||||
{ "nodeps", 0, NULL, 'D'},
|
||||
{ "quiet", 0, NULL, 'q'},
|
||||
{ "verbose", 0, NULL, 'v'},
|
||||
{ NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
applet = strdup (basename (service));
|
||||
atexit (cleanup);
|
||||
|
||||
/* Show help if insufficient args */
|
||||
if (argc < 3) {
|
||||
execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL);
|
||||
@ -838,6 +836,9 @@ int main (int argc, char **argv)
|
||||
applet, strerror (errno));
|
||||
}
|
||||
|
||||
applet = strdup (basename (service));
|
||||
atexit (cleanup);
|
||||
|
||||
#ifdef __linux__
|
||||
/* coldplug events can trigger init scripts, but we don't want to run them
|
||||
until after rc sysinit has completed so we punt them to the boot runlevel */
|
||||
@ -911,19 +912,15 @@ int main (int argc, char **argv)
|
||||
free (eb);
|
||||
}
|
||||
|
||||
/* Save the IN_BACKGROUND env flag so it's ONLY passed to the service
|
||||
that is being called and not any dependents */
|
||||
if (getenv ("IN_BACKGROUND")) {
|
||||
in_background = rc_is_env ("IN_BACKGROUND", "true");
|
||||
ibsave = strdup (getenv ("IN_BACKGROUND"));
|
||||
unsetenv ("IN_BACKGROUND");
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
/* Ok, we are ready to go, so setup selinux if applicable */
|
||||
setup_selinux (argc, argv);
|
||||
#endif
|
||||
|
||||
/* Punt the first arg as it's our service name */
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Right then, parse any options there may be */
|
||||
while ((c = getopt_long (argc, argv, "dhCDNqv",
|
||||
longopts, (int *) 0)) != -1)
|
||||
@ -951,6 +948,14 @@ int main (int argc, char **argv)
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Save the IN_BACKGROUND env flag so it's ONLY passed to the service
|
||||
that is being called and not any dependents */
|
||||
if (getenv ("IN_BACKGROUND")) {
|
||||
in_background = rc_is_env ("IN_BACKGROUND", "true");
|
||||
ibsave = strdup (getenv ("IN_BACKGROUND"));
|
||||
unsetenv ("IN_BACKGROUND");
|
||||
}
|
||||
|
||||
if (rc_is_env ("IN_HOTPLUG", "1")) {
|
||||
if (! rc_is_env ("RC_HOTPLUG", "yes") || ! rc_allow_plug (applet))
|
||||
eerrorx ("%s: not allowed to be hotplugged", applet);
|
||||
|
Loading…
Reference in New Issue
Block a user