Skip to content

Commit b3013d7

Browse files
committed
Fix evaluate_strictness to work when script executed with errexit
Fix based on #173 - thanks, Nikola! Fixes: #163
1 parent ccca1d6 commit b3013d7

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ Bianca Tamayo <hi@biancatamayo.me>
22
Conduitry <git@chor.date>
33
Felipe Santos
44
Matěj Týč <matej.tyc@gmail.com>
5+
Nicola Lunghi <nick83ola@gmail.com>
56
Stephen Gallagher <sgallagh@redhat.com>

src/function_generators.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ m4_define([_MAKE_RESTRICT_VALUES_FUNCTION], [MAKE_FUNCTION(
6767
_INDENT_()[@S|@2: The passed value]],
6868
[evaluate_strictness],
6969
[_INDENT_()_CASE_RESTRICT_VALUES([],
70-
[@<:@@<:@ "@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."],
71-
[@<:@@<:@ "@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_()],
70+
[! @<:@@<:@ "@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."],
71+
[! @<:@@<:@ "@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_()],
7272
)])
7373

7474

tests/regressiontests/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,9 @@ gen-test-group-wrong: $(TESTDIR)/gen-test-group-wrong.m4 $(ARGBASH_BIN)
744744
ERROR="'foo' is not a script argument" $(REVERSE) $(ARGBASH_EXEC) $< > /dev/null
745745

746746
$(TESTDIR)/test-semi_strict.sh: $(TESTDIR)/test-simple.m4 $(ARGBASH_BIN)
747-
printf "%s\n%s\n" "#!/bin/bash" "# ARG_RESTRICT_VALUES([no-local-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
747+
printf "%s\n%s\n" "#!/bin/bash" "set -e" "# ARG_RESTRICT_VALUES([no-local-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
748748
$(TESTDIR)/test-very_strict.sh: $(TESTDIR)/test-simple.m4 $(ARGBASH_BIN)
749-
printf "%s\n%s\n" "#!/bin/bash" "# ARG_RESTRICT_VALUES([no-any-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
749+
printf "%s\n%s\n" "#!/bin/bash" "set -e" "# ARG_RESTRICT_VALUES([no-any-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
750750
test-semi_strict: $(TESTDIR)/test-semi_strict.sh
751751
$< -o -x pos-arg | grep -q 'OPT_S=-x,'
752752
$< -o --opt-argx pos-arg | grep -q 'OPT_S=--opt-argx,'

tests/regressiontests/make/tests/tests-strict.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ADD_RULE([$(TESTDIR)/test-semi_strict.sh], [$(TESTDIR)/test-simple.m4 $(ARGBASH_BIN)],
2-
[[printf "%s\n%s\n" "#!/bin/bash" "# ARG_RESTRICT_VALUES([no-local-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -]])
2+
[[printf "%s\n%s\n" "#!/bin/bash" "set -e" "# ARG_RESTRICT_VALUES([no-local-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -]])
33

44
ADD_RULE([$(TESTDIR)/test-very_strict.sh], [$(TESTDIR)/test-simple.m4 $(ARGBASH_BIN)],
5-
[[printf "%s\n%s\n" "#!/bin/bash" "# ARG_RESTRICT_VALUES([no-any-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -]])
5+
[[printf "%s\n%s\n" "#!/bin/bash" "set -e" "# ARG_RESTRICT_VALUES([no-any-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -]])
66

77

88
dnl We have to pass a positional argument, so sometimes we pass 'pos-arg', sometimes stuff that looks like a option

0 commit comments

Comments
 (0)