completion tests: make the $cur variable local to the test helper functions

The test helper functions test_gitcomp() and test_gitcomp_nl() leak the $cur variable into the test environment. Since this variable has a special role in the Bash completion script (it holds the word currently being completed) it influences the behavior of most completion functions and thus this leakage could interfere with subsequent tests. Although there are no such issues in the current tests, early versions of the new tests that will be added later in this series suffered because of this. It's better to play safe and declare $cur local in those test helper functions. 'local' is bashism, of course, but the tests of the Bash completion script are run under Bash anyway, and there are already other variables declared local in this test script. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Feb 3, 2017 at 03:48 UTC eac90623bd8177ecdd8630dd96494a1d865fd516
1 file changed +2 -2
t/t9902-completion.sh
+2 -2
@@ -98,7 +98,7 @@ test_gitcomp ()
98 {
99 local -a COMPREPLY &&
100 sed -e 's/Z$//' >expected &&
101 - cur="$1" &&
101 + local cur="$1" &&
102 shift &&
103 __gitcomp "$@" &&
104 print_comp &&
@@ -113,7 +113,7 @@ test_gitcomp_nl ()
113 {
114 local -a COMPREPLY &&
115 sed -e 's/Z$//' >expected &&
116 - cur="$1" &&
116 + local cur="$1" &&
117 shift &&
118 __gitcomp_nl "$@" &&
119 print_comp &&