diff --git a/Makefile.am b/Makefile.am
index 718775ef3c50f0dc03d7775f0e64891b11aaf4f5..8aa64302b7893aa1f07bc52c4dace423c7cd4f59 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -351,6 +351,7 @@ srclink_files = \
 	$(all_python_code)
 
 check_python_code = \
+	autotools/build-bash-completion \
 	$(all_python_code)
 
 devel/upload: devel/upload.in $(REPLACE_VARS_SED)
diff --git a/autotools/build-bash-completion b/autotools/build-bash-completion
index 0d03cf83c7d3654dd30c3694574cd64628179367..aa130d42f289c7669ee60ffe3e4a82b9d3497feb 100755
--- a/autotools/build-bash-completion
+++ b/autotools/build-bash-completion
@@ -465,11 +465,11 @@ class CompletionWriter:
 
         if arg.min == 1 and arg.max == 1:
           cmpcode = """"$arg_idx" == %d""" % (last_arg_end)
+        elif arg.max is None:
+          cmpcode = """"$arg_idx" -ge %d""" % (last_arg_end)
         elif arg.min <= arg.max:
           cmpcode = (""""$arg_idx" -ge %d && "$arg_idx" -lt %d""" %
                      (last_arg_end, last_arg_end + arg.max))
-        elif arg.max is None:
-          cmpcode = """"$arg_idx" -ge %d""" % (last_arg_end)
         else:
           raise Exception("Unable to generate argument position condition")
 
@@ -487,7 +487,8 @@ class CompletionWriter:
             if choices:
               sw.Write("""choices="$choices "%s""", choices)
             if compgenargs:
-              sw.Write("compgenargs=%s", utils.ShellQuote(" ".join(compgenargs)))
+              sw.Write("compgenargs=%s",
+                       utils.ShellQuote(" ".join(compgenargs)))
           finally:
             sw.DecIndent()