summaryrefslogtreecommitdiffstats
path: root/win/tclWinInit.c
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2022-09-05 11:37:54 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2022-09-05 11:37:54 (GMT)
commit1197ccadc0ba24b8f5dc9debc59ca25593067f64 (patch)
treeea977af7c86f874349ac0e9004fcc5f8dd15f821 /win/tclWinInit.c
parentdc84ff9d0cfccec952277549d3b5031bd84c8860 (diff)
downloadtcl-1197ccadc0ba24b8f5dc9debc59ca25593067f64.zip
tcl-1197ccadc0ba24b8f5dc9debc59ca25593067f64.tar.gz
tcl-1197ccadc0ba24b8f5dc9debc59ca25593067f64.tar.bz2
Ticket [55a02f20ec] - fallback to USERPROFILE when setting HOME env on Windows
Diffstat (limited to 'win/tclWinInit.c')
-rw-r--r--win/tclWinInit.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 4f59c1a..eae4404 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -593,7 +593,14 @@ TclpSetVariables(
Tcl_SetVar2(interp, "env", "HOME", Tcl_DStringValue(&ds),
TCL_GLOBAL_ONLY);
} else {
- Tcl_SetVar2(interp, "env", "HOME", "c:\\", TCL_GLOBAL_ONLY);
+ /* None of HOME, HOMEDRIVE, HOMEPATH exists. Try USERPROFILE */
+ ptr = Tcl_GetVar2(interp, "env", "USERPROFILE", TCL_GLOBAL_ONLY);
+ if (ptr != NULL && ptr[0]) {
+ Tcl_SetVar2(interp, "env", "HOME", ptr, TCL_GLOBAL_ONLY);
+ } else {
+ /* Last resort */
+ Tcl_SetVar2(interp, "env", "HOME", "c:\\", TCL_GLOBAL_ONLY);
+ }
}
}