-
Notifications
You must be signed in to change notification settings - Fork 486
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
modify script executed from weird path (even when modify script is not templated) #2934
Comments
From the manual:
That could have been one way (if CHEZMOI_SOURCE_DIR and CHEZMOI_SOURCE_FILE had been set), except none of these appear to be set for |
chezmoi copies
Right now, you have to accept that you can't. Note that the
That was an oversight. Fixed in #2935. |
On Wed, 19 Apr 2023, 00:57 Tom Payne, ***@***.***> wrote:
chezmoi copies modify_ scripts to a file in a temporary directory, sets
the executable bit on the file, and then executes them. This is needed even
if the modify_ script is not a template as the executable bit is not set
in the source directory.
How do I get the original path to this file? Do I simply have to accept
that I can't, and make it a .tmpl and insert something like: source "{{
.chezmoi.sourceDir }}/{{ .chezmoi.sourceFile}}"?
Right now, you have to accept that you can't. Note that the
.chezmoi.sourceFile template variable does not exist.
Yes, it does. And I have used it successfully in modify scripts. It was
apparently added in #1210
That could have been one way (if CHEZMOI_SOURCE_DIR and CHEZMOI_SOURCE_FILE
had been set), except none of these appear to be set for modify_ scripts.
That was an oversight. Fixed in #2935
<#2935>.
Good, would be even better if the source file name was also exported this
way. :)
… —
Reply to this email directly, view it on GitHub
<#2934 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZJM2SENACGU7YB74CXDRTXB4L6TANCNFSM6AAAAAAXDG7JOE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
What exactly are you trying to do?
I was trying to be smart and inspect the path to the modify script (in order to detect an associated data file located relative to it). My modify script is actually a config file being executed by a rust program:
The idea was that the rust program would inspect the path to this
modify_
"script" to locate additional data files. However, when chezmoi actually executes this script the path is something like:/tmp/3306499162.Trolltech.conf
.This would make sense if the modify script was templated (
modify_blah.tmpl
) as chezmoi would need to replace things in the file. But that is not the case here, it is NOT a template. How do I get the original path to this file? Do I simply have to accept that I can't, and make it a.tmpl
and insert something like:source "{{ .chezmoi.sourceDir }}/{{ .chezmoi.sourceFile}}"
?Either way, I can't find where this behaviour is documented.
What have you tried so far?
Scratching my head at this (it is late local time...).
Where else have you checked for solutions?
Output of any commands you've tried with
--verbose
flagIrrelevant without the whole setup of my rust program. But if you really want to try it I can setup a test case.
Output of
chezmoi doctor
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: