aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-04-12 10:40:51 +0000
committerRoy Marples <roy@marples.name>2007-04-12 10:40:51 +0000
commit000f2395349552a9c1a08f634f1c5d1ed5417b1f (patch)
treef3a01f4c298f47ef716b4b36724d184c30635842
parent2728cef0e1b7f91fe1f23b3f85a50820743b75f2 (diff)
Fix getopt a little
-rw-r--r--src/mountinfo.c5
-rw-r--r--src/runscript.c27
2 files changed, 18 insertions, 14 deletions
diff --git a/src/mountinfo.c b/src/mountinfo.c
index 50e0716d..b7cc1b14 100644
--- a/src/mountinfo.c
+++ b/src/mountinfo.c
@@ -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));
diff --git a/src/runscript.c b/src/runscript.c
index 24512e25..ee32253a 100644
--- a/src/runscript.c
+++ b/src/runscript.c
@@ -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);