-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect when variables are declared and not set
It is possible to declare a variable but not assign a value to it using `export x`. When you do this, `declare -p x` shows the variable but does not show an "=" nor any value afterwards. When running another command, this variable will not be added to the environment variables even though it is flagged as exported. Most likely it's because the value is not a string and can't be easily converted to a string; this is the same behavior as arrays. Using `[[ -v x ]]` is also inadequate and I believe its because there are false positives when trying to access data, which goes on to break tests and the new braces and parenthesis indirection. Perhaps it could be reviewed and made to work. The best solution so far is to combine `declare -p` with `[[ -v` to see if the variable is declared and if a value is set. Closes #75.
- Loading branch information
Showing
3 changed files
with
25 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
cd "${0%/*}" || exit 1 | ||
. ../run-tests | ||
|
||
export uv | ||
export template='{{^uv}}OK{{/uv}}{{#uv}}FAIL{{/uv}}' | ||
export expected='OK' | ||
|
||
runTest |