Skip to content

Commit ccca1d6

Browse files
committed
Make sure that for Bash output, _key is local
and that does not happen for POSIX output. Fixes: #181
1 parent 82039f9 commit ccca1d6

File tree

6 files changed

+10
-0
lines changed

6 files changed

+10
-0
lines changed

bin/argbash

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,15 @@ stability: $(TESTDIR)/basic.sh $(TESTDIR)/basic2.sh
254254
basic: $(TESTDIR)/basic.sh
255255
$(generic_regression_posix)
256256
$(generic_regression_gnu_only)
257+
grep -q "local _key$$" $<
257258
$< -h | grep -q 'P percent: %'
258259
$< -h | grep -q 'O percent: %'
259260
! $< -h | grep -qe '\[--\]'
260261
test -z "$(SHELLCHECK)" || $(SHELLCHECK) "$(TESTDIR)/basic.sh"
261262
basic-dash: $(TESTDIR)/basic-dash.sh
262263
$(generic_regression_posix)
264+
! grep -q "local _key$$" $<
265+
$< LOO -b | grep -q BOOL=off,
263266
$< LOO -b | grep -q BOOL=off,
264267
$< -h | grep -q 'P percent: %'
265268
$< -h | grep -q 'O percent: %'

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

Lines changed: 3 additions & 0 deletions
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: %'

0 commit comments

Comments
 (0)