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>
This commit is contained in:
SZEDER Gábor 2017-02-03 03:48:11 +01:00 committed by Junio C Hamano
parent e5edbef48d
commit eac90623bd

View file

@ -98,7 +98,7 @@ test_gitcomp ()
{
local -a COMPREPLY &&
sed -e 's/Z$//' >expected &&
cur="$1" &&
local cur="$1" &&
shift &&
__gitcomp "$@" &&
print_comp &&
@ -113,7 +113,7 @@ test_gitcomp_nl ()
{
local -a COMPREPLY &&
sed -e 's/Z$//' >expected &&
cur="$1" &&
local cur="$1" &&
shift &&
__gitcomp_nl "$@" &&
print_comp &&