Skip to content

Startup and Standard Library

Chloë Strainge edited this page Oct 15, 2026 · 2 revisions

Startup and standard-library selection

Startup has separate administrator, library, and user steps. This lets a system profile select the standard library before user customization runs.

Startup order

For a login shell:

  1. Load /etc/shelly/profile.shy, when present.
  2. Load ~/.shelly_profile.shy, when present.
  3. Initialize the prelude, unless an earlier explicit reload already selected it.
  4. 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.

Standard-library search

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.

Find out what was selected

$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

Clone this wiki locally