Skip to content

Bug: Missing quotes in test_common.sh TFENV_ROOT check #457

@Zordrak

Description

@Zordrak

Description

In test/test_common.sh line 36, the TFENV_ROOT variable is tested without quotes:

[ -n ${TFENV_ROOT} ] || ...

Without quotes, [ -n ${TFENV_ROOT} ] will always evaluate to true even when TFENV_ROOT is empty, because an empty variable expands to nothing, leaving [ -n ] which tests whether the string -n is non-empty (it is).

With set -u enabled (which tfenv scripts use), an unset TFENV_ROOT would instead throw an "unbound variable" error before even reaching the test, but an empty-string TFENV_ROOT="" would silently pass this guard.

Expected

[ -n "${TFENV_ROOT}" ] || ...

Impact

If TFENV_ROOT is set but empty, the guard check passes incorrectly, and tests run with an empty root path, which could cause confusing failures or even destructive operations on /.

Found via

Code review of all source files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions