Overview
The dolang-shell crate provides a 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 flags:
--check-- check syntax without executing--compile <OUTPUT>-- compile to bytecode file
Scripts can use a shebang for direct execution:
Arguments after the script path are available as sys.args.
The executed script path is available as sys.program; when using -m, it is
the module name instead. In the REPL, sys.program is nil.
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 automatically imports a set of functions and objects into scope.
sys
| Name | Description |
|---|---|
echo |
Print arguments to terminal, separated by spaces |
exit |
Exit with a status code (default: 0) |
cd |
Change directory; optionally run func in new dir |
env |
Access environment variables |
args |
Command-line arguments (array) |
program |
Script Path or -m module name |
proc
| Name | Description |
|---|---|
sub |
Capture func's output as a string |
proc.run
| Name | Description |
|---|---|
Module as run |
Access external programs |