Commit 8adfb141 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

build-bash-completion: Check for None before comparing



Comparing a number with None is not a good idea:

  >>> (0 < None, 0 > None)
  (False, True)

This patch also adds build-bash-completion to the list
of checked Python scripts and wraps one line of more
than 80 characters.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent ab3e6da8
......@@ -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)
......
......@@ -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()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment