From ba07c4cf14e4061f8efafb3d4ec2031a0c0e0e51 Mon Sep 17 00:00:00 2001 From: Petr Vorel Date: Wed, 28 Jul 2021 18:33:21 +0200 Subject: [PATCH] pmbootstrap init: Fix regexp for int (MR 2086) This improves handling input in pmbootstrap init. Various config options in "Additional options" are int, thus whole input must be checked: This fixes obvious error: Jobs [9]: 5e and less obvious errors: Extra space size: 600.5 Extra space size: 600m ... $ pmbootstrap install [17:28:23] *** (3/4) PREPARE INSTALL BLOCKDEVICE *** [17:28:23] ERROR: invalid literal for int() with base 10: '600.5' NOTE: I suppose moving ^ $ to ReadlineTabCompleter.ask() would break some of already defined regexes. Signed-off-by: Petr Vorel --- pmb/config/init.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pmb/config/init.py b/pmb/config/init.py index a1e9e10a..5a2cac40 100644 --- a/pmb/config/init.py +++ b/pmb/config/init.py @@ -391,20 +391,20 @@ def ask_for_additional_options(args, cfg): " How much extra free space do you want to add to the image" " (in MB)?") answer = pmb.helpers.cli.ask(args, "Extra space size", None, - args.extra_space, validation_regex="[0-9]+") + args.extra_space, validation_regex="^[0-9]+$") cfg["pmbootstrap"]["extra_space"] = answer # Boot size logging.info("What should be the boot partition size (in MB)?") answer = pmb.helpers.cli.ask(args, "Boot size", None, args.boot_size, - validation_regex="[1-9][0-9]*") + validation_regex="^[1-9][0-9]*$") cfg["pmbootstrap"]["boot_size"] = answer # Parallel job count logging.info("How many jobs should run parallel on this machine, when" " compiling?") answer = pmb.helpers.cli.ask(args, "Jobs", None, args.jobs, - validation_regex="[1-9][0-9]*") + validation_regex="^[1-9][0-9]*$") cfg["pmbootstrap"]["jobs"] = answer # Ccache size