As of haku
v0.3 and just
v0.5.
Both scripts use their own syntax heavily inspired by Makefile one.
Feature | haku | just |
---|---|---|
Indentation | optional | required by syntax |
Comments | + | + |
Doc comments | + | + |
Multi-line command | + | + |
Multi-line strings | + | |
Multi-line constructs | + | |
String escapes | + | + |
Strings | one type | few types |
Math operators | very limited | very limited |
Environment variable support | + | + |
Variables | + | + |
Variable substitution | + | + |
Recipe parameters | + | + |
Recipe attributes | + | |
Recipe dependencies | + | + |
Recipe in other language | + | |
Private recipe | limited | + |
Import recipes from other files | + | |
Built-in flow control | + | |
Built-in functions | + | limited |
Dotenv integration | + | |
Single line/recipe modes | + | |
Aliases | + | |
Default shell | powershell on Windows, sh on other OS |
sh |
Custom shell | + | + |
Shell execution flags | + | + |
Error reporting | + | + |
Both applications allow a user to divide a long recipe line into a few smaller lines. In this case, every line
except the last one must end with \
.
While one can imitate multi-line string in haku
using \
character, it is not the same feature as just
provides.
By default both applications executes a script line by line. But there is difference:
In just
one cannot put, e.g., while
and its body to separate lines: the entire while
with its body must be a
single line. Yes, it can be separated with \
but, anyway, it is executed by a shell as a single huge command.
Haku
provides built-in control flow statements, so it is possible to run a real multi-line loop.
Just
has two string types: double-quoted one that supports escaped characters, and single-quotes raw strings.
haku
treats both type of string in the same way.
Just
supports only +
to concatenate strings,
Haku
supports only logical operators &&
, ||
, !
in logical conditions
Both allows a user to read and set environment variables values. The only difference: just
uses a separate function
env_var
to read the existing variable, while in haku
environment variable are used in the same way as any internal
variables: echo ${PATH}
. Haku
automatically reads a value from environment variable if a script variable with the
same name does not exist.
A slight difference in name conventions: just
requires all letters to be Latin letters, while haku
allows any
Unicode letters.
Assignment in just
is :=
, in haku
it is =
or ?=
.
Just
uses double curly braces and allows a script to use concatenation when a string is interpolated:
running {{date + testname}}
Haku
used Perl/Bash-style and only variable names are allowed - no operations or function calls:
running ${date} ${testname}
In both scripts one can use single value or list parameter for a recipe:
recipe param_single +param_list:
.
Just
allows setting default values for parameters: recipe param=default:
. In haku
it can be simulated with
assign-if-empty operator:
recipe param:
param ?= default
Just
may pass parameters to dependency: recipe: (build "main")
. It is not supported in haku
.
For just
recipe attributes are in roadmap and are not supported yet.
Haku
provides Rust-like attributes that can be applied to the entire recipe or to a single code block. That allows
a user to write cross-platform scripts:
#[family(windows)]
build-internal:
echo Building Windows version...
make -f mingw.makefile build
#[family(linux)]
build-internal:
echo Building Linux version...
make build
build: build-internal
There is no plans to support recipes in other languages in haku
. At this moment it can simulated by temporary
switching the current shell:
shell("python")
print 2+2
shell("bash", "-cu")
In haku
a user cannot create private recipes. Only few built-in private recipes exist, e.g, _default
.
Just
delegates all control statements(if
, for
etc) to external shell. So, the code that uses them is a
shell-dependent one.
Haku
introduces built-in for
, while
, if
and a few more control statements that works the same on any
platform and in any shell.
No application allows a user to create custom functions. But the number of built-in functions differs.
Just
provides only several functions that return various system information and works with environment variables.
Haku
, besides mentioned in just
, includes functions to format date and time, process strings, and file/directory paths.
Both applications supports @
to suppress printing a command before executing it in external shell.
In addition to it, haku
provides a flag -
that suppresses command errors and keep the script running even if
the command with this flag fails.
Both applications show the line number and the line that generates an error. Since haku
supports script import,
in case of more than one script is loaded, the error should show the name of the script which contain the failed line.