syshell
sy·shell is a system shell designed as an alternative to bash, fish, or nushell.
Why?
Language:
- Built-in formats support: JSON et al, no need for
jq. - Friendly syntax: no magic variables; reminicent of Python and Go.
- Rich types: work with dates, versions, IPs.
- Subcommands: create
git-style subcommands and parse options easily.
Runtime:
- Fast: handle CSV at 1GB/s per core.
- Cross platform: supports Linux, macOS, FreeBSD.
- Small footprint: <2MB, similar to bash.
More detailed comparison available here.
Why not?
It's in alpha and it's not fully implemented, e.g. no YAML, no Windows. The focus is to get the language and runtime right, then focus on the interactive shell and standard library.
How to Get It?
It is currently in a closed alpha. Fill out the form, if you want to try it out.
Examples
Release Script
:= declares a new variable |
|
the end of the tar command is determined by indent |
|
Disk Space Check
|
|
discard the first line of the df output, set the second
line to $line |
_, $line := df -k $targetMount |
split the line using :columns formatter, which splits
by spaces awk-style |
$stat := $line:columns |
:int converts a string to an integer |
|
use any expressions inside {} in strings |
|
Send a Slack Message
|
|
@json is also a formatter, but it's doing reverse of
:json. $payload@json convert a syshell object
(a map in this case) to a JSON string. |
|
panic stops current function and starts propagating an
error. If no one handles this error, syshell will print it along with a
stack trace. |
|
@json are @csv are also formatters,
@json converts from a syshell type to a string in a
specified format, @json is a reverse of :json.
Formatters always come in pairs.
Indent a File
for processess input line-by-line |
|
syshell works with external program's output as if they were a stream of lines.
Wait for an Event
Same as cat, just interactive. |
tail -f access.log |
in works like in python. |
|
for consumes items or lines as they come, once there's a
line with "/honeypot" inside, break will stop
to the loop, and tail -f will quit.
Countries Stats
Given a CSV file with cities stats like below, compute how many 1M+ population cities each country has:
>> head -4 cities.csv
"city","lat","lng","country","iso2","population"
"Tokyo","35.6897","139.6922","Japan","JP","37732000"
"Jakarta","-6.1750","106.8275","Indonesia","ID","33756000"
"Delhi","28.6100","77.2300","India","IN","32226000"
$countries := {} |
|
For each CSV record, create a map and send it over a pipe to a
for loop. |
|
put $countries |
Pipes in syshell can transport typed values without serialization overhead.
Disk Space Check Function
Function check-space must have exactly one argument,
which will be assigned to $mount. |
|
put adds typed value to the output stream. |
|
} |
|
$rootOK is a boolean, $left is an
integer. |
$rootOK, $left := check-space / |
put adds its arguments to the output stream as is, while
print converts arguments to strings and may output multiple
lines, if arguments have \n in them.
Build Function
|
|
| List function options and they will be set to specified variables | |
| Validate that supplied parameters have a correct type | |
|
|
|
Next Step
Read a language intro.
:columns,:intand:jsonare called formatters, they parse a string from a specified format to a syshell type. There are lots of built-in formatters that cover many scripting needs.