| SHTK(1) | General Commands Manual | SHTK(1) |
shtk — Interface
to the Shell Toolkit
shtk |
build [-m main_function]
[-o output_file]
[-s shell]
[input_file] |
shtk |
run [-m main_function]
[-s shell]
input_file [argument ...] |
shtk |
test [-m main_function]
[-s shell]
input_file ... |
shtk |
version |
The Shell Toolkit, or shtk for short, is a
collection of modules written in sh(1)
that provide common functionality to simplify the implementation of complex
shell scripts.
The tool described in this page, also named
shtk, is a program that accompanies the Shell
Toolkit and provides functionality that may be necessary to use the toolkit.
For documentation on the API, please see
shtk(3).
The interface of shtk is that of a program
with commands as shown in the synopsis section. The following subsections
describe the various commands supported by the tool.
The build command takes a script that uses
shtk modules and generates an executable script with
the necessary boilerplate code to be able to locate said modules.
The input_file argument specifies the path
to the file to process. This file should end with an ‘.sh’
extension, in which case the build command will proceed to generate a binary
of the same name without any extension. If the extension is not present,
then the name of the output file must be provided by specifying the
-o flag. The input file can also be
‘-’, in which case the code is read from the standard
input.
The following options are supported:
-m
main_function-m
shtk_unittest_main.
All scripts that use shtk should
implement a main function and should avoid placing any code at the top
level of the file. The main function is automatically executed by the
generated script. If the value of main_function is
empty, then no call to main is issued which may be necessary if the
script already has a call to main for whatever reason.
Default: ‘main’.
-o
output_fileDefault: if input_file ends in ‘.sh’, the output file has the same name as the input file but without the extension. Otherwise this flag must be specified.
-s
shellDefault: /usr/bin/bash.
The run command takes a script that uses
shtk modules, builds it into a temporary directory,
and executes the generated script. The temporary files are removed after
execution. This command is intended to simplify running scripts during
development; use the build command to generate a persistent executable.
The input_file argument specifies the path to the file to run. Unlike the build command, this argument cannot be ‘-’ because the standard input is left available to the executed script. Any arguments after the input file are passed unchanged to the script.
The following options are supported:
-m
main_functionDefault: ‘main’.
-s
shellDefault: /usr/bin/bash.
The run command exits with the exit status returned by the executed script.
The test command takes one or more scripts that use the shtk_unittest(3) module, builds them into temporary directories, and executes the generated test programs. The temporary files are removed after execution.
The input_file arguments specify the paths to the test programs to run. All input files are validated before any test program is executed. The test programs run sequentially in command-line order and execution continues if any of them fails. Unlike the build command, the input files cannot be ‘-’ because the standard input is left available to the test programs.
The following options are supported:
-m
main_functionDefault: ‘shtk_unittest_main’.
-s
shellDefault: /usr/bin/bash.
The test command exits successfully only if all test programs exit successfully.
The version command prints the name of the package and its version to the standard output. This command always exits successfully.
shtk modules.The shtk package was developed by
Julio Merino ⟨julio@meroh.net⟩.
| July 21, 2026 | Debian |