Testing tangled. Original: https://github.com/j6t/gitk

gitk: Tcl9 doesn't expand ~, use $env(HOME)

gitk looks for configuration files under $(HOME)/.., and uses the
typical shortcut formats to find this, e.g., ~/.config/. This relies
upon Tcl expanding such constructs to replace ~ with $(HOME). But, Tcl 9
has stopped doing that for various reasons, and now supplies [file
tildeexpand ...] to perform this expansion.

There are a very few places that need this expansion, and all must be
modified regardless of approach taken.

POSIX specifies that $HOME be defined at the time of login, and both
Cygwin and MSYS (underlying git for windows) set this variable. Tcl8
uses the POSIX defined pwnam to look up the underlying database record
on Unix, but will get the same result as using $HOME on any POSIX
compliant system. On Windows, Tcl just accesses $HOME, falling back to
other environment variables if $HOME is not set. Git for Windows has
$HOME defined by MSYS, so this works just as on the others.

As $env(HOME) works in Tcl 8 and 9, while anything using [file
tildeexpand ... ] will not, let's use the simpler approach as doing so
adds no lines of code.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>

+5 -5
+5 -5
gitk
··· 12469 12469 set config_file_tmp [file join $env(XDG_CONFIG_HOME) git gitk-tmp] 12470 12470 } else { 12471 12471 # default XDG_CONFIG_HOME 12472 - set config_file "~/.config/git/gitk" 12473 - set config_file_tmp "~/.config/git/gitk-tmp" 12472 + set config_file "$env(HOME)/.config/git/gitk" 12473 + set config_file_tmp "$env(HOME)/.config/git/gitk-tmp" 12474 12474 } 12475 12475 if {![file exists $config_file]} { 12476 12476 # for backward compatibility use the old config file if it exists 12477 - if {[file exists "~/.gitk"]} { 12478 - set config_file "~/.gitk" 12479 - set config_file_tmp "~/.gitk-tmp" 12477 + if {[file exists "$env(HOME)/.gitk"]} { 12478 + set config_file "$env(HOME)/.gitk" 12479 + set config_file_tmp "$env(HOME)/.gitk-tmp" 12480 12480 } elseif {![file exists [file dirname $config_file]]} { 12481 12481 file mkdir [file dirname $config_file] 12482 12482 }