Skip to content

Commit 8e19a11

Browse files
authored
Merge pull request #195 from matejak/various
Fix various minor issues
2 parents 449c870 + 4bd9437 commit 8e19a11

File tree

8 files changed

+17
-6
lines changed

8 files changed

+17
-6
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ Conduitry <[email protected]>
33
Felipe Santos
44
Kevin Stravers <[email protected]>
55
Matěj Týč <[email protected]>
6+
Nicola Lunghi <[email protected]>
67
Stephen Gallagher <[email protected]>

bin/argbash

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ print_help()
107107
parse_commandline()
108108
{
109109
_positionals_count=0
110+
local _key
110111
while test $# -gt 0
111112
do
112113
_key="$1"

bin/argbash-1to2

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ print_help()
5353
parse_commandline()
5454
{
5555
_positionals_count=0
56+
local _key
5657
while test $# -gt 0
5758
do
5859
_key="$1"

bin/argbash-init

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ print_help()
8585
parse_commandline()
8686
{
8787
_positionals_count=0
88+
local _key
8889
while test $# -gt 0
8990
do
9091
_key="$1"

src/function_generators.m4

+3-2
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

@@ -168,6 +168,7 @@ m4_define([_MAKE_ARGV_PARSING_FUNCTION], [MAKE_FUNCTION(
168168
[parse_commandline], [m4_do(
169169
[_JOIN_INDENTED(1,
170170
_IF_HAVE_POSITIONAL_ARGS([[_positionals_count=0],]),
171+
m4_if(m4_expand([_OUTPUT_TYPE]), [bash-script], [[local _key]]),
171172
[while test $[]# -gt 0],
172173
[do],
173174
)],

tests/regressiontests/Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,15 @@ stability: $(TESTDIR)/basic.sh $(TESTDIR)/basic2.sh
255255
basic: $(TESTDIR)/basic.sh
256256
$(generic_regression_posix)
257257
$(generic_regression_gnu_only)
258+
grep -q "local _key$$" $<
258259
$< -h | grep -q 'P percent: %'
259260
$< -h | grep -q 'O percent: %'
260261
! $< -h | grep -qe '\[--\]'
261262
test -z "$(SHELLCHECK)" || $(SHELLCHECK) "$(TESTDIR)/basic.sh"
262263
basic-dash: $(TESTDIR)/basic-dash.sh
263264
$(generic_regression_posix)
265+
! grep -q "local _key$$" $<
266+
$< LOO -b | grep -q BOOL=off,
264267
$< LOO -b | grep -q BOOL=off,
265268
$< -h | grep -q 'P percent: %'
266269
$< -h | grep -q 'O percent: %'
@@ -748,9 +751,9 @@ gen-test-group-wrong: $(TESTDIR)/gen-test-group-wrong.m4 $(ARGBASH_BIN)
748751
ERROR="'foo' is not a script argument" $(REVERSE) $(ARGBASH_EXEC) $< > /dev/null
749752

750753
$(TESTDIR)/test-semi_strict.sh: $(TESTDIR)/test-simple.m4 $(ARGBASH_BIN)
751-
printf "%s\n%s\n" "#!/usr/bin/env bash" "# ARG_RESTRICT_VALUES([no-local-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
754+
printf "%s\n%s\n" "#!/usr/bin/env bash" "set -e" "# ARG_RESTRICT_VALUES([no-local-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
752755
$(TESTDIR)/test-very_strict.sh: $(TESTDIR)/test-simple.m4 $(ARGBASH_BIN)
753-
printf "%s\n%s\n" "#!/usr/bin/env bash" "# ARG_RESTRICT_VALUES([no-any-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
756+
printf "%s\n%s\n" "#!/usr/bin/env bash" "set -e" "# ARG_RESTRICT_VALUES([no-any-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -
754757
test-semi_strict: $(TESTDIR)/test-semi_strict.sh
755758
$< -o -x pos-arg | grep -q 'OPT_S=-x,'
756759
$< -o --opt-argx pos-arg | grep -q 'OPT_S=--opt-argx,'

tests/regressiontests/make/tests/tests-base.m4

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ADD_TEST_BASH([stability], [[
66
ADD_TEST_BASH([basic], [[
77
$(generic_regression_posix)
88
$(generic_regression_gnu_only)
9+
grep -q "local _key$$" $<
910
$< -h | grep -q 'P percent: %'
1011
$< -h | grep -q 'O percent: %'
1112
! $< -h | grep -qe '\[--\]'
@@ -14,6 +15,8 @@ ADD_TEST_BASH([basic], [[
1415

1516
ADD_TEST_DASH([basic], [[
1617
$(generic_regression_posix)
18+
! grep -q "local _key$$" $<
19+
$< LOO -b | grep -q BOOL=off,
1720
$< LOO -b | grep -q BOOL=off,
1821
$< -h | grep -q 'P percent: %'
1922
$< -h | grep -q 'O percent: %'

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

+2-2
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" "#!/usr/bin/env bash" "# ARG_RESTRICT_VALUES([no-local-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -]])
2+
[[printf "%s\n%s\n" "#!/usr/bin/env 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" "#!/usr/bin/env bash" "# ARG_RESTRICT_VALUES([no-any-options])" | cat - $< | $(ARGBASH_BIN) -o $(@) -]])
5+
[[printf "%s\n%s\n" "#!/usr/bin/env 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)