`shellQuote` 处理反斜杠不正确
作者: mkalinski创建于 2026年8月12日更新于 2026年8月12日
DESCRIPTION
Describe the bug
shellQuote doubles backslashes in the returned string, which is not correct in POSIX shell single quotes, since backslashes have no special meaning there.
To reproduce
# "\\n" is needed here because Go templates interpret escapes in strings,
# shellQuote receives a single backslash here, without doubling it would receive a literal newline.
$ chezmoi execute-template '{{ shellQuote "\\n" }}'
'\\n'
# Expected behavior
```sh
$ chezmoi execute-template '{{ shellQuote "\\n" }}'
'\n'
# Output of `chezmoi doctor`
<details>
# RESULT
# CHECK
# MESSAGE
ok version v2.72.0, commit f81cb321789aa3df62871248f5e4d361a59e7cc1, built at 2026-08-03T00:00:00Z, built by Fedora
ok latest-version v2.72.0
ok os-arch linux/amd64 (Fedora Linux 44 (Sway))
ok build-info -tags=rpm_crashtraceback,noupgrade, CGO_ENABLED=1, GOEXPERIMENT=nodwarf5, GOAMD64=v1
ok uname Linux mk 7.1.8-200.fc44.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Aug 10 03:35:23 UTC 2026 x86_64 GNU/Linux
ok go-version go1.26.5-X:nodwarf5 (gc)
ok executable /usr/bin/chezmoi
ok config-file found ~/.config/chezmoi/chezmoi.toml, last modified 2026-07-25T21:05:04+02:00
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
error hardlink failed creating hardlink from ~/.local/share/chezmoi to /tmp: link ~/.local/share/chezmoi/.chezmoi-doctor-hardlink-test /tmp/chezmoi-doctor210992291/.chezmoi-doctor-hardlink-test: invalid cross-device link
ok symlink created symlink from .new-name to .old-name
ok umask 022
ok cd-command found /usr/bin/fish
ok cd-args /usr/bin/fish
info diff-command not set
ok edit-command found /usr/bin/nvim
ok edit-args /usr/bin/nvim
ok git-command found /usr/bin/git, version 2.55.0
ok merge-command found /usr/bin/nvim
ok shell-command found /usr/bin/fish
ok shell-args /usr/bin/fish
info age-command age not found in $PATH
ok gpg-command found /usr/bin/gpg, version 2.4.9
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
…内容来源: twpayne/chezmoi