]> git.notmuchmail.org Git - notmuch/commit - test/test-lib.sh
test-lib: mark function variables as local
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Fri, 8 May 2020 23:24:38 +0000 (19:24 -0400)
committerDavid Bremner <david@tethera.net>
Sat, 9 May 2020 11:32:51 +0000 (08:32 -0300)
commit627460d7bbbb6b95a07084c2b6fc7f647a5547e1
treef774143c548a0938ef3e0bbb6693f17a9a3bd391
parent02a2bf1b256f4eeb8c5e08129a2f0976da2569ce
test-lib: mark function variables as local

Several functions in test/test-lib.sh used variable names that are
also used outside of those functions (e.g. $output and $expected are
used in many of the test scripts), but they are not expected to
communicate via those variables.

We mark those variables "local" within test-lib.sh so that they do not
get clobbered when used outside test-lib.

We also move the local variable declarations to beginning of each
function, to avoid weird gotchas with local variable declarations as
described in https://tldp.org/LDP/abs/html/localvar.html.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
test/test-lib.sh