From 997e369691496be4ecfe38e3516f7e007ed69a7b Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Tue, 15 Apr 2014 10:58:21 +0200 Subject: [PATCH] pactl: Stop parsing option when the first non-option is encountered MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit fix bug https://bugs.freedesktop.org/show_bug.cgi?id=77108 see getopt(3): ""By default, getopt() permutes the contents of argv as it scans, so that eventually all the nonoptions are at the end. Two other modes are also implemented. If the first character of optstring is '+' or the envi‐ ronment variable POSIXLY_CORRECT is set, then option processing stops as soon as a nonoption argument is encountered. If the first character of optstring is '-', then each nonoption argv-element is handled as if it were the argument of an option with character code 1. (This is used by programs that were written to expect options and other argv-elements in any order and that care about the ordering of the two.) The special argument "--" forces an end of option-scanning regardless of the scan‐ ning mode."" prepend optstring with '+' to use POSIXLY_CORRECT mode Signed-off-by: Peter Meerwald --- src/utils/pactl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/pactl.c b/src/utils/pactl.c index 8483464f..555cb481 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -1596,7 +1596,7 @@ int main(int argc, char *argv[]) { proplist = pa_proplist_new(); - while ((c = getopt_long(argc, argv, "s:n:h", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "+s:n:h", long_options, NULL)) != -1) { switch (c) { case 'h' : help(bn); -- 2.39.2