File tree Expand file tree Collapse file tree 10 files changed +63
-2
lines changed
fixtures/workspaces/local-var-leak Expand file tree Collapse file tree 10 files changed +63
-2
lines changed Original file line number Diff line number Diff line change 11= view_marker
22
33> inspect_args() {
4+ > local k
5+ >
46> if ((${#args[@]})); then
57> readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
68> echo args:
@@ -17,8 +19,8 @@ if catch_all_used_anywhere?
1719> echo
1820> echo other_args:
1921> echo "- \${other_args[*]} = ${other_args[*]}"
20- > for i in "${!other_args[@]}"; do
21- > echo "- \${other_args[$i ]} = ${other_args[$i ]}"
22+ > for k in "${!other_args[@]}"; do
23+ > echo "- \${other_args[$k ]} = ${other_args[$k ]}"
2224> done
2325> fi
2426>
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ if root_command?
55else
66 > {{ function_name }}_parse_requirements() {
77end
8+ > local key
9+ >
810
911= render(:fixed_flags_filter).indent 2
1012= render(:environment_variables_filter).indent 2
Original file line number Diff line number Diff line change 1+ + bundle exec bashly generate
2+ creating user files in src
3+ skipped src/one_command.sh (exists)
4+ skipped src/two_command.sh (exists)
5+ skipped src/noop_command.sh (exists)
6+ created ./cli
7+ run ./cli --help to test your bash script
8+ + ./cli 1
9+ Before key=THIS IS MY VALUE
10+ noop called
11+ After key=THIS IS MY VALUE
12+ + ./cli 2
13+ Before k=THIS IS MY VALUE
14+ args:
15+ - ${args[--user]} = admin
16+ After k=THIS IS MY VALUE
Original file line number Diff line number Diff line change 1+ cli
Original file line number Diff line number Diff line change 1+ This fixture tests that variables that are supposed to be local, internal to
2+ bashly, are indeed defined as local and do not leak to the global scope.
3+
4+ Reference issue: https://github.com/bashly-framework/bashly/issues/681
Original file line number Diff line number Diff line change 1+ name : cli
2+ help : Testing that bashly-defined variables do not leak to the global scope
3+ version : 0.1.0
4+
5+ commands :
6+ - name : one
7+ alias : " 1"
8+ help : Testing 'key' leakage when calling 'run' internally
9+
10+ - name : two
11+ alias : " 2"
12+ help : Testing 'k' leak when calling 'inspect_args'
13+ flags :
14+ - long : --user
15+ arg : name
16+ default : admin
17+
18+ - name : noop
19+ help : Does nothing except declare it was called
Original file line number Diff line number Diff line change 1+ echo " noop called"
Original file line number Diff line number Diff line change 1+ key=" THIS IS MY VALUE"
2+ echo " Before key=$key "
3+ run noop
4+ echo " After key=$key "
Original file line number Diff line number Diff line change 1+ k=" THIS IS MY VALUE"
2+ echo " Before k=$k "
3+ inspect_args
4+ echo " After k=$k "
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -x
4+
5+ bundle exec bashly generate
6+
7+ ./cli 1
8+ ./cli 2
You can’t perform that action at this time.
0 commit comments