Problem
The current boolean env var handling in openemr.sh scripts accepts many different truthy/falsy values (1, yes, true, on, 0, no, false, off, etc.). This causes several problems:
- String matching everywhere - Every check requires
[[ "$VAR" = "true" ]] or similar
- Potential confusion -
on and no are easy to confuse/typo
- Inconsistent behavior - Different scripts may accept different subsets of values
- More code to maintain - The normalization function adds complexity
Proposal
Only accept literal true and false strings for boolean env vars:
validate_bool() {
local var_name=$1
local value=${!var_name}
case "$value" in
true|false) ;;
*) echo "Error: $var_name must be 'true' or 'false', got '$value'" >&2; exit 1 ;;
esac
}
Benefits
- Simpler checks - Can use
if $VAR; then directly since true and false are shell builtins
- No ambiguity - Clear, explicit values only
- Fail-fast - Invalid values caught immediately with helpful error message
- Less code - No normalization logic needed
Migration
- Update documentation to specify
true/false only
- Add validation that exits with a clear error message for invalid values
- Existing users with
EASY_DEV_MODE=1 or =yes will see a clear error telling them to use =true
Affected variables
EASY_DEV_MODE
EASY_DEV_MODE_NEW
INSANE_DEV_MODE
PCOV_ON
- And potentially others that currently accept
yes/no
Alternative considered
Keep the current normalization approach (accepting many values). Rejected because:
- Adds complexity for marginal user convenience
- Users can easily adapt to
true/false
- Clear error messages make the transition painless
Problem
The current boolean env var handling in
openemr.shscripts accepts many different truthy/falsy values (1,yes,true,on,0,no,false,off, etc.). This causes several problems:[[ "$VAR" = "true" ]]or similaronandnoare easy to confuse/typoProposal
Only accept literal
trueandfalsestrings for boolean env vars:Benefits
if $VAR; thendirectly sincetrueandfalseare shell builtinsMigration
true/falseonlyEASY_DEV_MODE=1or=yeswill see a clear error telling them to use=trueAffected variables
EASY_DEV_MODEEASY_DEV_MODE_NEWINSANE_DEV_MODEPCOV_ONyes/noAlternative considered
Keep the current normalization approach (accepting many values). Rejected because:
true/false