Repository navigation
Startup and Standard Library
Startup has separate administrator, library, and user steps. This lets a system profile select the standard library before user customization runs.
For a login shell:
- Load
/etc/shelly/profile.shy, when present. - Load
~/.shelly_profile.shy, when present. - Initialize the prelude, unless an earlier explicit reload already selected it.
- For an interactive shell, load the user RC, normally
~/.shelly_init.shy.
Non-login scripts do not read login profiles. The RC is interactive only;
--norc is unnecessary for ordinary script/test runs. --norc disables the user
RC, while login-profile handling is a separate decision. --rcfile selects an
alternate interactive RC file.
A profile may configure $SHELLY_STD_PATH before library initialization. It may
also call prelude_reload explicitly when it needs the selected prelude immediately.
The user RC receives the initialized prelude.
Set $SHELLY_TAB_SIZE in a profile or RC to choose the default tab stops for later
source parsing. Precedence is file #tab-size N, explicit --tab-width N, then
$SHELLY_TAB_SIZE, then 4. See pipeline splits for alignment rules.
When $SHELLY_STD_PATH is unset, filesystem defaults are searched left to right:
/etc/shelly/std:/usr/local/share/shelly/std:/usr/share/shelly/std
The embedded library supplies a fallback, allowing a single installed executable
to carry its own standard library. A set $SHELLY_STD_PATH replaces the defaults;
an empty value disables discovery. The special search entry bundled selects
the embedded library explicitly. It can be combined with filesystem directories
in a colon-separated override.
std::prelude resolves to prelude.shy or prelude/init.shy. Missing prelude
continues without it; the prelude never implicitly imports itself. The prelude
loads once per interpreter, and its public interface is reused for later modules.
$SHELLY_STD_FOUND reports the selected directory, the String embedded, or
() if no prelude was found. It does not point to prelude.shy. It reports the
prelude source, not a claim that every subsequently imported standard module
came from that same directory when multiple search roots are configured.
Writing $SHELLY_STD_PATH changes search configuration; it does not silently
replace existing type identities. prelude_reload explicitly refreshes the
current scope and future modules after successful loading. Already-loaded modules
keep their bindings, and existing values retain their original type identities.
std:: imports use only standard-library search. Ordinary imports use local
lookup followed by $SHELLY_MODULE_PATH, never $SHELLY_STD_PATH.
Related: Modules · Environment · Prompts
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