chezmoi: `output` template function does not cause template rendering to fail
To help find out the issues, the output template function should cause the template rendering to fail if the command which it runs returns a non-zero status code. If someone wants to ignore the status code, it can be worked around with something like output "sh" "-c" "my-command || true".
I took a long time to realize that the chezmoi installation were failing on newly installed systems because curl was not installed before the template runs, then my variables were empty. Instead, I should have been warned by chezmoi that output failed the same way that for example, semverCompare fails if a non-valid string is supplied as input.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (16 by maintainers)
Commits related to this issue
- Fix error being ignored by chezmoi template Refs https://github.com/twpayne/chezmoi/issues/1466\#issuecomment-929678533 — committed to felipecrs/dotfiles by felipecrs 3 years ago
It’s expected, and there isn’t much that can be done to work around it. The way is to avoid using command substitution like that.
It’s funny how Bash can be complicated. I will watch out on my scripts much more now. Instead of doing things like:
I should probably do:
Hm… I’m trying to reproduce it to make sure.