]> git.cworth.org Git - fips/commitdiff
Stop processing command-line options at first non-option argument
authorCarl Worth <cworth@cworth.org>
Tue, 25 Jun 2013 23:48:13 +0000 (16:48 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 25 Jun 2013 23:48:13 +0000 (16:48 -0700)
This makes it much easier to pass options to the program being
executed by fips. The options can be passed directly, such as:

fips glxgears -fullscreen

Previous, to this commit, one would have to use a syntax such as:

fips -- glxgears -fullscreen

to prevent fips from trying to interpret the "-fullscreen" argument as
options to fips itself.

fips.c

diff --git a/fips.c b/fips.c
index 02f67bb80fd1e6983d4680d132f19c966f2e8065..fca2da8ec7c6e6df1c9d199e8e3f5b470d088548 100644 (file)
--- a/fips.c
+++ b/fips.c
@@ -43,7 +43,17 @@ main (int argc, char *argv[])
 {
        int opt, ret;
 
-       const char *short_options = "h";
+       /* The initial '+' means that getopt will stop looking for
+        * options after the first non-option argument. This means
+        * that a command such as:
+        *
+        *      fips glxgears -fullscreen
+        *
+        * Will do what is intended, (namely, have fips invoke
+        * "glxgears -fullscreen" rather than trying to interpret
+        * -fullscreen as options to fips itself.
+        */
+       const char *short_options = "+h";
        const struct option long_options[] = {
                {"help", no_argument, 0, 'h'},
                {0, 0, 0, 0}