Getting started

shtk is a tool and a library. The tool, shtk(1), provides the mechanisms to "compile" an shtk script into a runnable script. The library, shtk(3), provides a collection of shell modules with different functionality.

Here is the typical "Hello, world!" program built with shtk. Start by creating a source file, say with the following contents:

shtk_import cli

main() {
    shtk_cli_info "Hello, world!"

Now, build and run it:

$ shtk build
$ ./hello
hello: I: Hello, world!

You can also write test programs with shtk. A simple integration test for our sample program, which we store as, would look like this:

shtk_import unittest

shtk_unittest_add_test hello_prints_hello_world_to_stderr
hello_prints_hello_world_to_stderr_test() {
    assert_command -e inline:"hello: I: Hello, world!\n" ../hello

You can build and run the test just like the original program, but specifying a different entry point:

$ shtk build -m shtk_unittest_main
$ ./hello_test
hello_test: I: Testing hello_prints_hello_world_to_stderr...
Running checked command: ../hello
hello_test: I: Testing hello_prints_hello_world_to_stderr... PASSED
hello_test: I: Ran 1 tests; ALL PASSED

Reference manual

The manual pages below correspond to shtk 1.8.