the shok command shell

shok:~ : echo "Welcome to shok"
Welcome to shok
shok:~ : {
shok:~ >     new foo = "world"
shok:~ >     : echo Hello {foo}
shok:~ > }
Hello world

shok is a cross-platform non-POSIX interactive command shell. Similar to bash and cmd.exe, it allows the user to invoke programs and script their execution. shok will provide a secure, platform-agnostic, and user-friendly programming language that is designed to facilitate filesystem interaction and system management.


  • secure shell environment
  • user-friendly syntax
  • clean embedded programming language
  • platform-independent semantics suitable for system administration
  • facilitate filesystem manipulation, job management, program invocation
  • Free and open-source software (GPLv3+)

shok is in the very early stages of development, and is not currently usable. A reference compiler is under heavy development, and many features are planned, but most are unimplemented or still under discussion. The examples on this page are mockups from the future and do not work yet! We also understand that it is dangerous to use a shell that has not withstood rigorous testing. If you are interested in shok, please get involved in the language and compiler development!

The shok approach:

A command shell is a program that lets the user run other programs. It also provides a programming language for scripting the invocation of programs and some interactions between them.

In haiku:

all there is to shok

{ write code in curly braces }

: colon runs commands

Most command shells have lousy scripting languages, in part because the programming syntax needs to disguise itself around (or make itself a part of) the shell's default action: running programs. Alternatively, programming languages often provide an ability to invoke external programs, but usually it is difficult or impossible to use as an interactive shell. (With a few exceptions — notably, Julia does a pretty good job.)

shok takes a different approach to minimize this trade-off. It provides a natural syntax for switching between the command shell and a fully-featured programming language.

shok:~ : cd
shok:~ : echo hello
shok:~ : mkdir foo
shok:~ : touch foo/file.txt                   
shok:~ : 
shok:~ : {
shok:~ >     new authors_file = 'authors.txt'
shok:~ > }
shok:~ : touch {authors_file}
shok:~ : 
shok:~ : echo I have {4*3} hearts: { '<3 '.repeat(12) }
I have 12 hearts: <3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3 
shok:~ : 
shok:~ : {
shok:~ >     print("Use : to make a command-line statement")
shok:~ >     : mkdir research
shok:~ >     new some_date = date(2013, 4, 17)
shok:~ >     : echo My date is {some_date}
shok:~ > }
Use : to make a command-line statement
My date is 2013-4-17
shok:~ : 
shok:~ : {
shok:~ >     each f:file in ~/download/ {
shok:~ >>        if f.modification_time >= some_date {
shok:~ >>>           print("Copying " ~ f ~ " to my research dir.")
shok:~ >>>           : cp {f} research/
shok:~ >>>           : grep AUTHORS {f} >> {authors_file}
shok:~ >>>       }
shok:~ >>    }
shok:~ > }
Copying /home/mike/download/algorithms.pdf to my research dir.
Copying /home/mike/download/biology.pdf to my research dir.
shok:~ : 

The above examples demonstrate:

  • A { at the start of a command-line switches into a code block of the programming language.
  • The first (outermost) scope is special — its variables are global, and can be accessed even after the closing }.
  • {}'s in the middle of a command-line can be used to pull code (variables and expressions) onto the command-line.
  • Retrieving a value this way is safe — a string can't be misinterpreted as shell code!
  • Within code, use ':' at the start of a line to write a command-line statement.
  • A code block is not executed until the last block is closed, and the code compiles with no errors.
  • The language has features like "path literals" that complement shell programming.

The modes page describes the different ways to switch from the command-line to code, and vice-versa.

Other features:

  • Familiar shell tools like pipes and redirection, with some improvements.
  • Security-conscious transitions between language constructs and program invocation.
  • Object-oriented programming with "static prototypes".
  • Strongly, statically-typed and compilable language: prevent errors before destructive program invocations can occur.
  • Lexically-scoped, copy-by-value memory model: predictable, automatic memory management without garbage collection.
  • Safe programming with controlled object ownership and mutation semantics.

Get involved!

Learn more:

  • Some weak motivation for writing a whole new command shell.
  • Ways to change modes between the command-line and the programming language.
  • Information about the compiler's strange implementation.
  • More info coming soon!

Contribute and hang out:

The source code is currently hosted on GitHub. Clone the project:
git clone 'git@github.com:nfomon/shok.git'

Please note that it is in the very early stages of development, and probably won't even compile. If it does, be careful! Consider this a call for hackers.

shok is free software licensed under the GNU GPL v3+. Its development relies on a community of developers, supporters, and financial givers. To help bring it to life, you can contribute with code or by donating bitcoins to: 1MgmzHtr5ZwaVSoRzEWN7iwEMf3CZ6bhzF.

Most importantly, join the discussion! A mailing list is on the way. For now, come hang out on IRC: freenode #shok. Feedback, ideas, gripes, and lurkers are welcome.

Last updated: 2014-02-04