Closed pwm1234-sri closed 2 years ago
The path separator in Windows is a backslash \
, which is interpreted as an escape character in strings in most languages. You do not observe the problem on Linux because Linux uses a forward slash as the path separator.
chezmoi provides text templating, and it is your responsibility to ensure that the file generated by your template is correct. You might find the quote
template function useful, for example:
{{ .chezmoi.homeDir | quote }}
Describe the bug
When I use
chezmoi init
on windows with the variable.homeDir
in a toml config file,.chezmoi.toml.tmpl
, chezmoi generates an error with an error message about unescaped characters. This does not happen on linux.The error also does not happen when using a yaml config file. (I did not try a json config file - I want to use either yaml or toml, so I can include comments, so json is not a good choice.) This is not a serious problem for me since yaml is just as good for me as toml, but I thought I should let you know.
Chezmoi seems like a great tool, and I am excited to be using it. Thanks!
To reproduce
Put
.chezmoi.homeDir
in thedata
section of a.chezmoi.toml.tmpl
file and runchezmoi init
on windows.Expected behavior
The template expansion contains
c:\Users\MyUserName
.Additional context
Add any other context about the problem here.