Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
SHTK(1)			FreeBSD	General	Commands Manual		       SHTK(1)

     shtk -- Interface to the Shell Toolkit

     shtk build	[-m main_function] [-o output_file] [-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 ac-
     companies the Shell Toolkit and provides functionality that may be	neces-
     sary to use the toolkit.  For documentation on the	API, please see

     The interface of shtk is that of a	program	with commands as shown in the
     synopsis section.	The following subsections describe the various com-
     mands supported by	the tool.

   The build command
     The build command takes a script that uses	shtk modules and generates an
     executable	script with the	necessary boilerplate code to be able to lo-
     cate 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
	   Name	of the function	that implements	the entry point	of the pro-
	   gram.  For programs using the shkt_unittest(3) module, this should
	   be passed as	-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 is-
	   sued	which may be necessary if the script already has a call	to
	   main	for whatever reason.

	   Default: `main'.

     -o	output_file
	   Path	to the output file to generate.

	   Default: 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	shell
	   Path	to the shell interpreter to write in the shebang line of the

	   Default: /bin/sh.

   The version command
     The version command prints	the name of the	package	and its	version	to the
     standard output.  This command always exits successfully.

	   Overrides the built-in location of the modules.

	   Colon-separated list	of directories in which	to look	for modules.
	   SHTK_MODULESDIR is always implied at	the end	of the path.  The user
	   can define this variable to point to	other directories.  This is
	   especially handy in packages	that install custom modules and	want
	   to use such modules before installing them.

	   Overrides the built-in location of the default shell	interpreter.

	   Location of the shtk	modules.


     The shtk package was developed by Julio Merino <>.

FreeBSD	13.0		       November	8, 2014			  FreeBSD 13.0


Want to link to this manual page? Use this URL:

home | help