Treat environment variable values beginning with "T" as true

So a value is true iff it begins with 'T', 't', 'Y', or 'y'.  This is
mostly so that naively converting JSON "true" to a string will work
properly, but it should keep LISPers happy too.
This commit is contained in:
Ben Harris
2023-03-22 17:56:10 +00:00
parent 6dac51795e
commit 0632a3c2e4

2
misc.c
View File

@ -202,7 +202,7 @@ bool getenv_bool(const char *name, bool dflt)
{ {
char *env = getenv(name); char *env = getenv(name);
if (env == NULL) return dflt; if (env == NULL) return dflt;
if (env[0] == 'y' || env[0] == 'Y') return true; if (strchr("yYtT", env[0])) return true;
return false; return false;
} }