Repository navigation
Commands and Exit Status
At command position, Shelly resolves language functions and then external programs.
Arguments such as diff in git diff are ordinary words. Group an invocation to
execute it inside an argument: git (diff).
::name bypasses interpreter definitions and searches for an external program.
Paths such as /usr/bin/printf also identify programs directly.
fn printf($message: String): String { "wrapped: ${message}" }
echo (printf "hello")
::printf '%s\n' "external hello"
wrapped: hello
external hello
A bare word initializing a variable is executed: let $result = task.
task must resolve at runtime. Quote it to store text, or use a backtick reference
to retain a validated callable without invoking it. See Functions.
ExecResult describes an external program's completion. Code zero is true;
nonzero codes and signal termination are false. A function's returned Boolean
uses ordinary Boolean truth instead.
let $result = /usr/bin/false
if $result { echo "completed" } else { echo "not completed" }
echo $result
not completed
ExecResult(1)
Here /usr/bin/false is an external utility. The Boolean literal is false in expression
position; an unambiguous comparison or a typed value can be used when needed.
A captured status is handled by the script. An uncaptured failed command aborts
that execution; the REPL reports it and accepts another command.
Built-ins such as cd and exit affect Shelly itself. A child program cannot
change its parent's working directory. Use exit N to choose an explicit script
exit code.
alias heading = echo "Dispatch:"
heading "northbound"
Dispatch: northbound
Aliases provide command-name shortcuts with literal default arguments. They are expanded at command lookup, and alias cycles are rejected. They do not replace functions for calculations or structured data processing. Syntax reference shows their declaration form.
Globs and argument spreading are separate: an unquoted glob selects filesystem
paths, while $items... supplies array items as separate arguments. Quote a glob
when the program itself should interpret it.
Related: Running Shelly · Redirection · Pipelines
Begin here
Values and expressions
- Language basics
- Variables and scope
- Numbers and logic
- Strings and paths
- Arrays
- Hash maps
- Ranges and iteration
- Control flow
- Match and type guards
Functions and types
- Functions and calls
- Closures and function types
- Methods and properties
- Structs
- Enums
- Named types and unions
- Conversions
- Types and properties
Shell and modules
- Pipelines
- Pipeline splits
- Pipeline formats
- Commands and exit status
- Redirection
- Environment and exported variables
- Modules and visibility
- Nested modules and directory packages
- Conditional imports and declarations
- Errors and cleanup
- Supervised processes and terminals
Library guides
- Standard library
- The implicit prelude
- Bytes, files, readers, and writers
- Explicit item streams
- JSON documents and typed mapping
- Sockets, DNS, and TLS
- HTTP clients
- HTTP servers
- Framing, server-sent events, and JSON-RPC
- Terminal colors, styles, and geometry
- Build an application console
Interactive use