From 2d839c1c425f5c7d08750c12538a33b07122ef1c Mon Sep 17 00:00:00 2001 From: Nicola Lunghi <25422924+nicola-lunghi@users.noreply.github.com> Date: Mon, 3 Oct 2022 09:57:32 +0100 Subject: [PATCH] function_generators: evaluate_strictness: return 0 if function succeeded If the [[ a =~ b]] comparison return false, the function returns false as well. This makes the script exit if I set the errexit options if the input are valid This fixes issue https://github.com/matejak/argbash/issues/163 --- src/function_generators.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/function_generators.m4 b/src/function_generators.m4 index 6b2ced1..819a8d6 100644 --- a/src/function_generators.m4 +++ b/src/function_generators.m4 @@ -67,8 +67,8 @@ m4_define([_MAKE_RESTRICT_VALUES_FUNCTION], [MAKE_FUNCTION( _INDENT_()[@S|@2: The passed value]], [evaluate_strictness], [_INDENT_()_CASE_RESTRICT_VALUES([], - [@<:@@<:@ "@S|@2" =~ ^-(-(m4_list_join([_ARGS_LONG], [|]))$|m4_dquote(m4_list_join([_ARGS_SHORT], []))) @:>@@:>@ && die "You have passed '@S|@2' as a value of argument '@S|@1', which makes it look like that you have omitted the actual value, since '@S|@2' is an option accepted by this script. This is considered a fatal error."], - [@<:@@<:@ "@S|@2" =~ ^--?@<:@a-zA-Z@:>@ @:>@@:>@ && die "You have passed '@S|@2' as a value of argument '@S|@1'. It looks like that you are trying to pass an option instead of the actual value, which is considered a fatal error."])_ENDL_()], + [ ! @<:@@<:@ "@S|@2" =~ ^-(-(m4_list_join([_ARGS_LONG], [|]))$|m4_dquote(m4_list_join([_ARGS_SHORT], []))) @:>@@:>@ || die "You have passed '@S|@2' as a value of argument '@S|@1', which makes it look like that you have omitted the actual value, since '@S|@2' is an option accepted by this script. This is considered a fatal error."], + [ ! @<:@@<:@ "@S|@2" =~ ^--?@<:@a-zA-Z@:>@ @:>@@:>@ || die "You have passed '@S|@2' as a value of argument '@S|@1'. It looks like that you are trying to pass an option instead of the actual value, which is considered a fatal error."])_ENDL_()], )])