summaryrefslogtreecommitdiff
path: root/debian/patches/89_saner_argv_lists.patch
blob: f9d4edf9f6721a0ae583edd4a016da10cf126ead (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Make parsing of lists given on the command line more intuitive.  Debian
#336343.


Depends on 88_fix_argv_loop.patch



--- a/jack_argv.py~	2005-11-01 19:30:34.000000000 +0000
+++ b/jack_argv.py	2005-11-01 19:41:11.000000000 +0000
@@ -117,11 +117,23 @@
     if ty == types.ListType:
         l = []
         if origin == "argv":
+            valid_short_opts = [cf[key]['short'] for key in cf.keys() if cf[key].has_key('short')]
+            valid_long_opts = [cf[key]['long'] for key in cf.keys() if cf[key].has_key('long')]
             while 1:
                 i, data = get_next(argv, i, alt_arg, 0)
                 if data != None:
                     if data == ";":
                         break
+                    # The end of a list has to be signaled with a semicolon but
+                    # many users forget this; therefore, check whether the next list
+                    # entry is a valid option, and if so, assume the end of the list
+                    # has been reached.
+                    if data.startswith("--") and data[2:].split('=', 1)[0] in valid_long_opts:
+                        i -= 1
+                        break
+                    if data.startswith("-") and len(data) == 2 and data[1] in valid_short_opts:
+                        i -= 1
+                        break
                     l.append(data)
                     if alt_arg: # only one option in --opt=val form
                         break