]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
bash completion: Fix help option parsing.
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 3 May 2025 18:07:34 +0000 (20:07 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 18 May 2025 17:19:02 +0000 (19:19 +0200)
If we complete on para_client or para_audioc options rather than on server
or audiod subcommands, we parse the --help output to determine the options to
complete on. The regular expression we currently use for that is too lenient
because it also matches the options in the synopsis section of the help output.

Fix this by prefixing the expression with '^' to extract only the options
of the subsequent help text.

bash_completion

index 88b37dc28fb0dc175f48ac9fa364f26a434bedde..5135101b65755792c78b9bd339241638fb765fcc 100644 (file)
@@ -8,11 +8,11 @@ _para_complete()
 
        # This extracts short and long options from the help output
        local script='{
-               if ($1 ~ "-[a-zA-Z]," && $2 ~ "--[a-zA-Z]") {
+               if ($1 ~ "^-[a-zA-Z]," && $2 ~ "^--[a-zA-Z]") {
                        print substr($1, 0, 2);
                        gsub("=.*", "", $2)
                        print $2
-               } else if ($1 ~ "--[a-zA-Z]") {
+               } else if ($1 ~ "^--[a-zA-Z]") {
                        gsub("=.*", "", $1)
                        print $1
                }