Variables and Substitution
Variables, strings, concatenation, path joining, and substitution using {{…}}
are supported:
tmpdir := `mktemp -d`
version := "0.2.7"
tardir := tmpdir / "awesomesauce-" + version
tarball := tardir + ".tar.gz"
publish:
rm -f {{tarball}}
mkdir {{tardir}}
cp README.md *.c {{tardir}}
tar zcvf {{tarball}} {{tardir}}
scp {{tarball}} me@server.com:release/
rm -rf {{tarball}} {{tardir}}
Joining Paths
The /
operator can be used to join two strings with a slash:
foo := "a" / "b"
$ just --evaluate foo
a/b
Note that a /
is added even if one is already present:
foo := "a/"
bar := foo / "b"
$ just --evaluate bar
a//b
Absolute paths can also be constructed1.5.0:
foo := / "b"
$ just --evaluate foo
/b
The /
operator uses the /
character, even on Windows. Thus, using the /
operator should be avoided with paths that use universal naming convention
(UNC), i.e., those that start with \?
, since forward slashes are not
supported with UNC paths.
Escaping {{
To write a recipe containing {{
, use {{{{
:
braces:
echo 'I {{{{LOVE}} curly braces!'
(An unmatched }}
is ignored, so it doesn’t need to be escaped.)
Another option is to put all the text you’d like to escape inside of an interpolation:
braces:
echo '{{'I {{LOVE}} curly braces!'}}'
Yet another option is to use {{ "{{" }}
:
braces:
echo 'I {{ "{{" }}LOVE}} curly braces!'