You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to use variables in commands with backticks? #1292
So a few things are preventing this from working. First, just variables are distinct from shell variables, so you'll need to use the export keyword to export them:
However, assignments are not processed in the order that they appear in a source file, so exported variables aren't available in backticks within the same scope, so GIT_COMMIT still wouldn't be available to the backtick assigned to GIT_TIME.
Hopefully we'll eventually support some kind of syntax that allows this, perhaps #799 or #822, but it might be a while! Sorry I don't have better news!
Activity
runeimp commentedon Jul 27, 2022
My guess is that all or multiple lines like that are processed concurrently or at least not in order. Though @casey would know for sure. 😇
casey commentedon Jul 28, 2022
So a few things are preventing this from working. First,
justvariables are distinct from shell variables, so you'll need to use theexportkeyword to export them:However, assignments are not processed in the order that they appear in a source file, so exported variables aren't available in backticks within the same scope, so
GIT_COMMITstill wouldn't be available to the backtick assigned toGIT_TIME.Hopefully we'll eventually support some kind of syntax that allows this, perhaps #799 or #822, but it might be a while! Sorry I don't have better news!
PotatoesFall commentedon Jul 28, 2022
Ah okay that's clear, thanks. I'm sure I'll find another solution for my problem :)
melMass commentedon Mar 20, 2024
Sorry to bump an old issue but just to be sure, this is not possible to escape variables directly either right?
(I use nushell here but you can replace the idea with
realpath {{justfile_directory() / ".."}EDIT: actually in my case the execution pwd in in fact justfile_directory.. so unrelated but this works fine:
root := `".." | path expand`casey commentedon Mar 20, 2024
That's correct, interpolations in backticks aren't supported.
pniederlag commentedon Apr 26, 2024
to bad... still true in 2024 ?
runiq commentedon Apr 24, 2026
You can use the
shell()function, which just takes a string, which you can construct the usual way. For example:casey commentedon Apr 24, 2026
There are a few other ways to make this nicer: