NAME
bx
– shell script and task runner
SYNOPSIS
bx [options] path [arg...]
bx [options] task [arg...]
bx [options] [-- arg...]
DESCRIPTION
The build2
shell script and task runner executes a
script (first form) or a task (second and third form) with optional
arguments.
The first argument after options
determines whether
it is a shell script path or a task name. It is considered a script if it
contains the directory separator or the .bx
extension.
Otherwise, it is considered a task name. Absent first argument means the
default task. In this case the --
separator must be used
if you wish to pass arguments to the default task. Note that neither the
script path nor task name can start with -
.
Note that task running is not yet implemented.
The recommended first line ("shebang") for an executable script is as follows:
#! /usr/bin/env bx
OPTIONS
DEFAULT OPTIONS FILES
Instead of having a separate config file format for tool configuration,
the build2
toolchain uses default options files
which contain the same options as what can be specified on the command line.
The default options files are like options files that one can specify with
--options-file
except that they are loaded by
default.
The default options files for bx
are called
bx.options
, bx-script.options
(shell
script only), and bx-task.options
(task only) and are
searched for in the .build2/
subdirectory of the home
directory and in the system directory (for example,
/etc/build2/
) if configured. Note that besides options
the bx-task.options
file can also contain global
variable overrides (@@ only for task running?).
Once the search is complete, the files are loaded in the reverse order,
that is, beginning from the system directory (if any), followed by the home
directory, and finishing off with the options specified on the command line.
For each directory bx.options
, if found, is loaded
first, followed by bx-script.options
for a shell script
and bx-task.options
for a task. In other words, the
files are loaded from the more generic to the more specific with the command
line options having the ability to override any values specified in the
default options files.
If a default options file contains
--no-default-options
, then the search is stopped at the
directory containing this file and no outer files are loaded. If this option
is specified on the command line, then none of the default options files are
searched for or loaded.
An additional directory containing default options files can be specified
with --default-options
. Its configuration files are
loaded after the home directory.
The order in which default options files are loaded is traced at the
verbosity level 3 (-V
option) or higher.
EXIT STATUS
In case of a script execution, the script exit code is returned. In case of a task execution, non-zero exit status is returned in case of an error.
ENVIRONMENT
The HOME
environment variable is used to determine
the user's home directory. If it is not set, then
getpwuid(3)
is used instead. This value is used to
shorten paths printed in diagnostics by replacing the home directory with
~/
. It is also made available to scripts as the
shell.home
variable.
The BUILD2_DEF_OPT
environment variable is used to
suppress loading of default options files in nested runner invocations. Its
values are false
or 0
to suppress
and true
or 1
to load.
BUGS
Send bug reports to the users@build2.org mailing list.