From 50179b0bb70bbfcb9b56eba698d984c198d9e73b Mon Sep 17 00:00:00 2001 From: David Howells Date: Tue, 13 May 2014 17:26:40 +0100 Subject: [PATCH] Handle negative numeric command line arguments Handle negative numeric command line arguments, distinguishing them from flags that begin with dashes. Signed-off-by: David Howells --- suite/argparse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/suite/argparse.py b/suite/argparse.py index 66c5513..07745b9 100644 --- a/suite/argparse.py +++ b/suite/argparse.py @@ -155,7 +155,7 @@ def parse_arguments(args, available_arguments, argument_size_limits, match = False params = [] - if args[i][0] != "-": + if args[i][0] != "-" or args[i][1:].isnumeric(): # Deal with positional arguments if need_switch: raise AFSArgumentError("Need switch before argument " + i) @@ -173,7 +173,7 @@ def parse_arguments(args, available_arguments, argument_size_limits, if match[2][1] == "m": # All remaining arguments up to the next switch belong to this while i < len(args): - if args[i][0] == "-": + if args[i][0] == "-" and not args[i][1:].isnumeric(): break params.append(args[i]) i = i + 1 @@ -207,7 +207,7 @@ def parse_arguments(args, available_arguments, argument_size_limits, # Arrange the parameters associated with the switch into a list while i < len(args): - if args[i][0] == "-": + if args[i][0] == "-" and not args[i][1:].isnumeric(): break params.append(args[i]) i = i + 1 -- 2.49.0