Skip to content

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:

dolang-shell script.dol

With the --strict flag, compiler warnings are treated as errors (runtime errors always propagate if uncaught, regardless of this flag):

dolang-shell --strict script.dol

Other flags:

  • --check -- check syntax without executing
  • --compile <OUTPUT> -- compile to bytecode file

Scripts can use a shebang for direct execution:

#!/usr/bin/env -S dolang-shell --strict
echo Hello from Do!

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:

dolang-shell

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