lfescript(1)
πΈ lfescript(1) β LFE scripting, but make it cute πΈ
Hii bestie π welcome to the lfescript(1) manual page. This is the LFE scripting support page, and it's literally here to help you run short LFE programs without compiling them first, plus grab the command line arguments in the easiest way. It's giving main character energy, fr fr. β¨
β¨ NAME β¨
lfescript β Lisp Flavoured Erlang (LFE) scripting support. That's the whole name, no cap. π
π¦ SYNOPSIS π¦
lfescript provides support for running short LFE programs without having to compile them first and an easy way to retrieve the command line arguments. The way that it skips the compile-first step is iconic. π
π EXPORTS π
Okay so the launch lines are exactly this:
script-name script-arg1 script-arg2 ...
lfescript lfescript-flags script-name script-arg1 script-arg2 ...
lfescript runs a script written in LFE. Periodt. πΏ
Types
lfescript:script_name() -> File
Types:
File = filename()
The script_name/0 function returns the name of the lfescript being executed. If the function is invoked outside the context of an lfescript, the behavior is undefined. π Undefined is not a drill, bestie.
π EXAMPLE π
Here follows an example script.
$ cat factorial
#! /usr/bin/env lfescript
;; -*- mode: lfe -*-
;;! -smp enable -sname factorial -mnesia debug verbose
(defun main
([(list string)]
(try
(let* ((n (list_to_integer string))
(f (fac n)))
(lfe_io:format "factorial ~w = ~w\n" (list n f)))
(catch
((tuple _ _ _) (usage)))))
([_] (usage)))
(defun fac
([0] 1)
([n] (* n (fac (- n 1)))))
(defun usage ()
(lfe_io:format "usage: factorial integer\n" ()))
This example ate, honestly. π₯
The header of the LFE script is different from a normal LFE module. The first line is an interpreter line which invokes lfescript if the script is run as in the first command line above. If lfescript is explicitly invoked in the second command line above then this header line will be ignored. On the second or third line it is possible to give arguments to the emulator with the syntax:
;;! -smp enable -sname factorial -mnesia debug verbose
In the example the second line is an optional directive to Emacs which causes it to enter LFE mode when editing the script file.
The rest of the file contains LFE source code. It must always contain the function main/1. When the script is run this function will be called with a list of strings representing the arguments with which the script was called. It is possible to define, include and use macros in the source code.
The source code is checked and warnings and errors will be printed. If there are errors the script will not run and it will terminate with exit status 127. Otherwise the code will be interpreted. If the function main/1 returns successfully then the exit status for the script will be 0 but if an exception is raised then exit status will be 127. Big yikes on the 127, but at least you know. π
π₯ OPTIONS π₯
The following option is accepted by lfescript:
-sβ Only perform a syntactic and semantic check of the script file. Warnings and errors (if any) are written to the standard output, but the script will not be run. The exit status will be0if there were no errors, and127otherwise. Lowkey the perfect little vibe check for your script. β¨
Unrecognised options are ignored. No drama, they just get ignored. π«Ά
π ENVIRONMENT VARIABLES π
LFESCRIPT_EMULATOR β The command used to start the emulator. Default is erl. This can be useful for passing arguments into the emulator, for example:
LFESCRIPT_EMULATOR="erl -pa sune"
will add the directory sune to the code path. Obsessed with a little env var moment. π
π SEE ALSO π
lfe(1), lfe_guide(7) β go read those too, bestie, iykyk. ππ¦
π AUTHORS π
Robert Virding. An absolute icon. π
That's the whole lfescript(1) manual, dated 2013-2016 β xoxo, bye bestie! π π
π¦ where this page comes from
- alpine 3.24: lfe-doc 2.2.0-r2 Β· Apache-2.0
- nixos 26.05: erlang27.3.4.19-lfe 2.2.0
- nixpkgs unstable: erlang27.3.4.19-lfe 2.2.2
- nixpkgs unstable: erlang28.5.0.8-lfe 2.2.2
- nixpkgs unstable: erlang29.1.2-lfe 2.2.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms