2.7 KiB
2.7 KiB
Fun executable: full usage guide
This document explains how to use the fun binary after building or installing it: invocation patterns, options, environment variables, include/search paths, REPL, and examples.
Synopsis
fun [options] [<script.fun>] [-- args...]
- If
<script.fun>is provided,funruns the script. - If omitted and the build enables the REPL,
funstarts an interactive session.
Options
-i,--repl— start the interactive REPL explicitly (if built with REPL support)-v,--version— print version and exit-h,--help— show usage info and exit
Notes:
- Available options may vary by build configuration. Always check
fun --helpfor your binary.
Exit codes
0— success- non‑zero — error during parse, compile, or runtime
Standard library and includes
fun searches for modules included from .fun code in these locations:
- The path provided by the environment variable
FUN_LIB_DIR(highest precedence) - The compiled‑in default
DEFAULT_LIB_DIR(configured during build/install)
Tips:
- When running from the repository without installing, set
FUN_LIB_DIRto the local./libdirectory so examples can find the stdlib. - See also:
docs/includes.mdfor namespacing (include ... as ...) and search order details.
REPL
If interactive mode is enabled at build time, starting fun with -i (or without a script) opens the REPL.
Useful commands/patterns in REPL:
- Enter expressions and statements directly.
- Use arrow keys/history for editing (availability depends on build flags).
- See
docs/repl.mdfor details and tips.
Running scripts
Basic run (installed system‑wide):
fun /usr/share/fun/examples/hello.fun
Running from a build tree (not installed):
FUN_LIB_DIR=./lib /path/to/build_dir/fun examples/hello.fun
Passing arguments to scripts (arguments after -- are forwarded to the script environment):
fun myscript.fun -- arg1 arg2
Build and install locations
- Build targets:
funis produced by thefuntarget. In CLion/CMake, typical build directories arebuild_debugorbuild_release. - Install locations (by default):
- Binary:
/usr/bin/fun - Stdlib:
/usr/share/fun/lib - Examples (optional):
/usr/share/fun/examples
- Binary:
To stage an install without touching the system:
DESTDIR=./tmp/stage cmake --build <build_dir> --target install
./tmp/stage/usr/bin/fun ./examples/hello.fun
See also
docs/cli.md— concise CLI reference (synopsis/options/exit codes)docs/funstx.md— syntax checker for.funfiles with optional--fixdocs/examples.md— how to run the bundled examplesdocs/includes.md— include paths, namespacing, andFUN_LIB_DIR