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 hello.sh with the following contents:
shtk_import cli
main() {
shtk_cli_info "Hello, world!"
}
During development, you can run it directly:
$ shtk run hello.sh hello: I: Hello, world!
Once the script is ready, use shtk build hello.sh to create the persistent hello executable.
You can also write test programs with shtk. A simple integration test for our hello.sh sample program, which we store as hello_test.sh, 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 run one or more test programs directly:
$ shtk test hello_test.sh 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
Or you can also build it:
$ shtk build -m shtk_unittest_main hello_test.sh $ ./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
The manual pages below correspond to shtk 1.8.