Closed renemarc closed 4 years ago
Thank you for the very clear and complete report!
I agree that chezmoi's current behavior here is undesirable. In practice, symlink targets rarely should contain either leading or trailing whitespace, so it makes sense to unconditionally strip any.
Describe the bug
When using a
symlink_xxxx.tmpl
file to auto-create a symbolic link, any newline characters are included in the resulting target name. The link then ends up pointing to a non-existing file. Since many GUI code editors automatically add an empty line at the end of the file upon saving, the name of the resulting target may end with an unwelcome\n
.A template-based workaround is to include a space-trimming comment at the end:
{{- /* eof */ -}}
To reproduce
touch iterm.plist
echo iterm.plist >> .chezmoiignore
.example
, including a trailing newline:touch symlink_iterm.plist.tmpl
Edit the template to point to the regular file, but include an empty line at the end:
chezmoi apply
.The resulting link is:
Expected behavior
Ideally, the template results should be trimmed on both ends to remove any heading and trailing spaces.
Output of command with
--verbose
Output of
chezmoi doctor
Additional context
N/A.