dbus/tools dbus-launch.c,1.19,1.20
Thiago J. Macieira
thiago at kemper.freedesktop.org
Sun Oct 1 15:21:32 PDT 2006
Update of /cvs/dbus/dbus/tools
In directory kemper:/tmp/cvs-serv4756/tools
Modified Files:
dbus-launch.c
Log Message:
* tools/dbus-launch.c (main): make it complain and abort
execution in case an unknown option is given. Also, process
the '--' argument as the end of arguments.
Index: dbus-launch.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/dbus-launch.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- dbus-launch.c 1 Oct 2006 20:05:39 -0000 1.19
+++ dbus-launch.c 1 Oct 2006 22:21:30 -0000 1.20
@@ -612,6 +612,7 @@
int bourne_shell_syntax = FALSE;
int auto_shell_syntax = FALSE;
int autolaunch = FALSE;
+ int requires_arg = FALSE;
int i;
int ret;
int bus_pid_to_launcher_pipe[2];
@@ -627,7 +628,7 @@
while (i < argc)
{
const char *arg = argv[i];
-
+
if (strcmp (arg, "--help") == 0 ||
strcmp (arg, "-h") == 0 ||
strcmp (arg, "-?") == 0)
@@ -635,13 +636,13 @@
else if (strcmp (arg, "--auto-syntax") == 0)
auto_shell_syntax = TRUE;
else if (strcmp (arg, "-c") == 0 ||
- strcmp (arg, "--csh-syntax") == 0)
+ strcmp (arg, "--csh-syntax") == 0)
c_shell_syntax = TRUE;
else if (strcmp (arg, "-s") == 0 ||
- strcmp (arg, "--sh-syntax") == 0)
+ strcmp (arg, "--sh-syntax") == 0)
bourne_shell_syntax = TRUE;
else if (strcmp (arg, "--binary-syntax") == 0)
- binary_syntax = TRUE;
+ binary_syntax = TRUE;
else if (strcmp (arg, "--version") == 0)
version ();
else if (strcmp (arg, "--exit-with-session") == 0)
@@ -675,9 +676,10 @@
autolaunch = TRUE;
save_machine_uuid (arg);
+ requires_arg = FALSE;
}
else if (strcmp (arg, "--autolaunch") == 0)
- ; /* wait for next arg */
+ requires_arg = TRUE;
else if (strstr (arg, "--config-file=") == arg)
{
const char *file;
@@ -703,9 +705,24 @@
}
config_file = xstrdup (arg);
+ requires_arg = FALSE;
}
else if (strcmp (arg, "--config-file") == 0)
- ; /* wait for next arg */
+ requires_arg = TRUE;
+ else if (arg[0] == '-')
+ {
+ if (strcmp (arg, "--") != 0)
+ {
+ fprintf (stderr, "Option `%s' is unknown.\n", arg);
+ exit (1);
+ }
+ else
+ {
+ runprog = argv[i+1];
+ remaining_args = i+2;
+ break;
+ }
+ }
else
{
runprog = arg;
@@ -717,6 +734,11 @@
++i;
}
+ if (requires_arg)
+ {
+ fprintf (stderr, "Option `%s' requires an argument.\n", prev_arg);
+ exit (1);
+ }
if (auto_shell_syntax)
{
More information about the dbus-commit
mailing list