Overview
The dolang-shell crate provides the dolang script executor and REPL for
the Do language. It extends the core language with shell-oriented features like
process spawning, environment variable access, and file I/O.
Running Scripts
Run a Do script from the command line:
With the --strict flag, compiler warnings are treated as errors (runtime
errors always propagate if uncaught, regardless of this flag):
Other options:
-m,--main-- run a bundled entrypoint instead of a script--check-- check syntax without executing--compile OUTPUT-- compile to bytecode file--module-path PATH-- add a module search path (repeatable)--import MODULE[=NAME]-- add a module to the prelude (repeatable)--import-item MODULE.ITEM[=NAME]-- add a module item to the prelude (repeatable)--no-cache-- disable reading and writing the bytecode cache-h,--help-- show command-line help
Explicit module paths are searched in command-line order before the site/
directory and bundled modules. See Modules and Caching.
Prelude options supplement the default. An alias after =
changes the name bound in the script:
Scripts can use a shebang for direct execution:
Arguments after the script path are available as shell.args.
The executed script path is available as shell.program.
Bundled Entrypoints
-m runs an entrypoint bundled with dolang:
Symlink aliases such as dodo and dolang-test select the corresponding
entrypoint implicitly when available.
Companion Programs
A complete installation contains three main executables:
dolang-- script executor, bundled entrypoints, and REPLdolang-lsp-- language serverdolang-vfs-- VFS server
REPL
Launch an interactive REPL with no arguments:
The REPL provides an interactive environment where you can evaluate Do expressions and statements. Variables and definitions persist across lines within a session.
Shell Prelude
The shell prelude extends the core-language prelude. Every core prelude value remains available, and the shell additionally imports the following functions and objects.
shell
| Name | Description |
|---|---|
exit |
Exit with a status code (default: 0) |
cd |
Change directory; optionally run func in new dir |
env |
Access environment variables |
Module as shell |
Shell context and control |
term
| Name | Description |
|---|---|
echo |
Print sanitized arguments separated by spaces |
print |
Print concatenated terminal output |
proc
| Name | Description |
|---|---|
sub |
Capture func's output as a string |
run |
Run external programs |