Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template function quote doesn't work for pointers #4007

Closed
KapJI opened this issue Oct 20, 2024 · 2 comments · Fixed by #4009
Closed

Template function quote doesn't work for pointers #4007

KapJI opened this issue Oct 20, 2024 · 2 comments · Fixed by #4009
Labels
bug Something isn't working in dependency In a dependency, not in chezmoi

Comments

@KapJI
Copy link
Contributor

KapJI commented Oct 20, 2024

Describe the bug

quote, squote and quoteList return quoted pointer value instead of quoted string this pointer points to.

To reproduce

{{- $release := (gitHubLatestRelease "sharkdp/bat").Assets | first -}}
Name: {{ $release.Name }}
Name quote: {{ $release.Name | quote }}
Name quoteList: {{ list $release.Name | quoteList }}
Name type: {{ $release.Name | kindOf }}

Prints:

Name: bat-musl_0.24.0_amd64.deb
Name quoted: '0xc000a841b0'
Name quoteList: ["0xc00078ad80"]
Name type: ptr

Expected behavior

{{ $ptr | quote }} returns quoted {{ $ptr }}. In the meantime "{{ $ptr}}" can be used as a replacement.

Additional context

I know that quote is coming from sprig, quoteList is first party though. sprig is not very well supported and this behaviour can be very confusing for chezmoi users. I guess that's one more reason to replace sprig with something better like proposed in #2668

@KapJI KapJI changed the title Template function quote doesn't work with pointers Template function quote doesn't work for pointers Oct 20, 2024
@halostatue halostatue added the bug Something isn't working label Oct 20, 2024
@halostatue
Copy link
Collaborator

halostatue commented Oct 20, 2024

I have confirmed this. This won't be easy to resolve (there are a number of places where this would need changing, and fixing it would likely require the use of a sprig fork), but even piping through toString fails. This, at a minimum, should be shored up to convert *string to string so that even if something like $ptr | quote won't work because of the difficulties involved, $ptr | toString | quote or list $ptr | toStrings | quoteList absolutely work.

@twpayne
Copy link
Owner

twpayne commented Oct 20, 2024

Thanks for reporting this. #4007 should fix it for quote and quoteList at least. sprig's implementation of squote is hilariously broken, so I don't propose to attempt to fix this.

@twpayne twpayne added the in dependency In a dependency, not in chezmoi label Oct 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working in dependency In a dependency, not in chezmoi
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants