mdawar.dev

A blog about programming, Web development, Open Source, Linux and DevOps.

Justfile Lazy Command Evaluation

Commands in backticks are always evaluated in a Justfile, even if not used.

In just version v1.47.0 , a lazy evaluation setting was added to skip the evaluation of unused variables.

Justfile
# Lazily evaluate commands inside backticks.
set lazy

# A variable that reads the contents of a file.
file_contents := `cat data.txt`

# The variable is not evaluated for this recipe.
write_file:
    echo "Lazy command evaluation" > data.txt

# The variable is evaluated only when used.
read_file:
    echo {{ file_contents }}