Fleck is a Clojure-like LISP that runs wherever Bash is.
curl -s https: // chr 15 m.github.io/flk/flk>flk&&chmod 755 flk ./flk
Examples|Reference|FAQ|make-a-lisp
$ echo '(println "Hello world!") (println "Hostname:" (sh * "hostname")))'>example.clj $ ./flk example.clj Hello world! Hostname: diziet
Now you can use a humble LISP to do Bash things. Bash as a scripting language has many edges, but it is everywhere. Fleck attempts to round off the edges.
Almost all of this code is from themake- a-LISPproject. All I’ve done is put together a simple Makefile to package it up into an easily deployable single-file bash script.
A list of macros and functions that are present in Fleck.
Built-ins
This is the set of built-ins from the make-a-lisp project. These more or less work but are generally more limited in functionality than their Clojure equivalents. For example the addition function( )
can only add two numbers at a time.
def!
Defmacro!
if
do
FN *
Try *
sh *
let *
quote
Quasiquote
macroexpand
type
=
throw
nil?
true?
false?
string?
symbol
symbol?
keyword
keyword?
number?
fn?
macro?
pr-str
str
PRN
println
readline
read-string
slurp
>
>=
-
*
/
time-ms
list
list?
vector
Vector?
hash-map
map?
Assoc
dissoc
get
contains?
keys
vals
sequential?
cons
Concat
nth
first
rest
empty?
count
apply
map
conj
SEQ
with-meta
meta
ATOM
Atom?
Deref
Reset!
Swap!
Extras
These functions are defined in Fleck itself or pulled in from themal / lib /
folder.
pprint
str-replace
str-split
(str-replace STRING FIND REPLACE)
– Replace all occurrences of the stringFIND
inSTRING
with the string REPLACE .(str-split STRING SPLIT-CHARACTER) (Split) ****************************** (STRING) into a list of strings on the single characters (SPLIT-CHARACTER) .
Aliases
These are wrappers around the limited internal versions of the make-a-lisp macros and functions and are much more limited than the Clojure equivalents.
let
when
def
FN
defn
You can compile your Fleck script to a one which runs in pure Bash without Fleck. This works by bundling the Fleck sources with your script. Say you have a Fleck script calledwow.clj
, you can compile it as follows.
make DEST=wow INSERT=. / wow.clj NOREPL=1
This will produce a new standalone executable script calledwow
which will bundlewow.clj
into Fleck and it will be called at run time.
Think of this as homoiconic Bash rather than Clojure, and code as if you’re in Bash.
Will my favorite piece of Clojure run in this?
No, it’s bash.
Why can’t I add more than 2 numbers together?
It’s bash. Try invoking bc:(sh * "bc
Where are the floating point numbers?
It’s bash. Try invoking bc:(sh * "bc
Why can’t I iterate on a string?
It’s bash. Try(seq "somestring")
.
How do I do destructuring?
You can’t.
Why is it called Fleck?
At (k and running on any machine with Bash, the name seemed appropriate.)
fleck n. A tiny mark or spot. n. A small bit or flake.
GIPHY App Key not set. Please check settings