2001-09-13 Gergely Nagy * src/main.c (main): allow multiple --command arguments on the commandline, and execute them all, not just the last one diff -urd ratpoison.orig/src/main.c ratpoison/src/main.c --- ratpoison.orig/src/main.c Sun Sep 9 22:32:17 2001 +++ ratpoison/src/main.c Thu Sep 13 11:52:32 2001 @@ -391,8 +391,11 @@ int do_kill = 0; int do_restart = 0; int do_command = 0; - char *command = NULL; + char **command; + int cmd_count = 0; + int cmd_allocated = 0; + command = NULL; myargv = argv; /* Parse the arguments */ @@ -418,8 +421,16 @@ do_restart = 1; break; case 'c': - command = xmalloc (strlen (optarg) + 1); - strcpy (command, optarg); + if (!command) + command = xmalloc (sizeof(char *)); + if (cmd_count >= cmd_allocated) + { + command = xrealloc (command, sizeof(char *) * (cmd_count + 1)); + command[cmd_count] = xmalloc (strlen (optarg) + 1); + cmd_allocated++; + } + strcpy (command[cmd_count], optarg); + cmd_count++; do_command = 1; break; default: @@ -456,8 +467,15 @@ } if (do_command) { - send_command (command); - free (command); + int i; + + for (i = 0; i < cmd_count; i++) + { + send_command (command[i]); + free (command[i]); + sleep (2); + } + free(command); XCloseDisplay (dpy); return EXIT_SUCCESS; }