summaryrefslogtreecommitdiff
path: root/t/t9902-completion.sh
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2017-02-03 02:48:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-02-04 06:18:39 (GMT)
commiteac90623bd8177ecdd8630dd96494a1d865fd516 (patch)
tree1c82ea176351302c920749ebe7175bf50c4c54e3 /t/t9902-completion.sh
parente5edbef48db005ef00d65389eecf50c1321c18e8 (diff)
downloadgit-eac90623bd8177ecdd8630dd96494a1d865fd516.zip
git-eac90623bd8177ecdd8630dd96494a1d865fd516.tar.gz
git-eac90623bd8177ecdd8630dd96494a1d865fd516.tar.bz2
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>
Diffstat (limited to 't/t9902-completion.sh')
-rwxr-xr-xt/t9902-completion.sh4
1 files changed, 2 insertions, 2 deletions
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index f490c1d..294a08c 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -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 &&