twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.9k stars 478 forks source link

chezmoi data -f yaml incorrectly renders "\n" as |4+ #3594

Closed ErrrorMaxx closed 6 months ago

ErrrorMaxx commented 6 months ago

Describe the bug

chezmoi data -f yaml incorrectly renders "\n" as |4+

To reproduce

In .chezmoi.yaml.tmpl:

data:
  NL: "\n"

Run chezmoi data -f yaml

Expected behavior

"\n" rendered as "\n" (like "\t" which properly renders as "\t")

Output of command with the --verbose flag

$ chezmoi --verbose data -f yaml
NL: |4+
chezmoi:
...

Output of chezmoi doctor

```console $ chezmoi doctor RESULT CHECK MESSAGE warning version v2.46.1 ok latest-version v2.46.1 ok os-arch android/arm64 ok uname Linux localhost 4.19.191+ #1 SMP PREEMPT Wed Nov 29 21:44:22 CST 2023 aarch64 Android ok go-version go1.21.6 (gc) ok executable /data/data/com.termux/files/usr/bin/chezmoi ok config-file ~/.config/chezmoi/chezmoi.yaml, last modified 2024-02-24T11:50:36Z ok source-dir ~/.local/share/chezmoi is a git working tree (clean) ok suspicious-entries no suspicious entries ok working-tree ~/.local/share/chezmoi is a git working tree (clean) ok dest-dir ~ is a directory warning umask 077 ok cd-command found /data/data/com.termux/files/usr/bin/zsh ok cd-args /data/data/com.termux/files/usr/bin/zsh info diff-command not set ok edit-command found /data/data/com.termux/files/usr/bin/micro ok edit-args micro ok git-command found /data/data/com.termux/files/usr/bin/git, version 2.43.2 warning merge-command vimdiff not found in $PATH ok shell-command found /data/data/com.termux/files/usr/bin/zsh ok shell-args /data/data/com.termux/files/usr/bin/zsh info age-command age not found in $PATH ok gpg-command found /data/data/com.termux/files/usr/bin/gpg, version 2.4.4 info pinentry-command not set info 1password-command op not found in $PATH info bitwarden-command bw not found in $PATH info bitwarden-secrets-command bws not found in $PATH info dashlane-command dcli not found in $PATH info doppler-command doppler not found in $PATH info gopass-command gopass not found in $PATH info keepassxc-command keepassxc-cli not found in $PATH info keepassxc-db not set info keeper-command keeper not found in $PATH info lastpass-command lpass not found in $PATH info pass-command pass not found in $PATH info passhole-command ph not found in $PATH info rbw-command rbw not found in $PATH info vault-command vault not found in $PATH info vlt-command vlt not found in $PATH info secret-command not set ```
twpayne commented 6 months ago

This is https://github.com/go-yaml/yaml/issues/1004.

This bug is in a dependency of chezmoi and cannot be fixed in chezmoi itself. chezmoi's dependencies are regularly updated and so when this is fixed in the dependency chezmoi will get the fix soon after. So, I will close this as won't fix.

Note, however, that if you have a template variable for newlines you should probably be using a template line ending directive instead, i.e. your templates should contain

chezmoi:template:line-endings=native