├── site ├── CNAME ├── footer.html.in ├── styles.css ├── index.html.frag ├── docs.html.frag └── header.html.in ├── AUTHORS ├── shtk.pc.in ├── .github └── workflows │ ├── lint.yml │ ├── site.yml │ ├── test.yml │ └── build.sh ├── .gitignore ├── .pre-commit-config.yaml ├── man ├── README ├── shtk_git.3 ├── shtk_process.3 ├── shtk_hw.3 ├── shtk_cli_progname.3 ├── shtk_fs.3 ├── shtk_cli_dirname.3 ├── shtk_cleanup.3 ├── shtk_list.3 ├── shtk_unittest_expect_equal.3 ├── shtk_unittest_expect_file.3 ├── shtk_unittest_expect_command.3 ├── shtk_unittest_expect_not_equal.3 ├── shtk_bool.3 ├── shtk_cli.3 ├── shtk_git_update.3 ├── shtk_config_get.3 ├── shtk_config_get_bool.3 ├── shtk_unittest_assert_equal.3 ├── shtk_list_contains.3 ├── shtk_cvs.3 ├── shtk_config_include.3 ├── shtk_unittest_assert_not_equal.3 ├── shtk_config_get_default.3 ├── shtk_config_init.3 ├── shtk_version_is.3 ├── shtk_fs_join_paths.3 ├── shtk_version_at_most.3 ├── shtk_git_clone.3 ├── shtk_config_set.3 ├── shtk_config_has.3 ├── shtk_list_filter.3 ├── shtk_unittest_delayed_fail.3 ├── shtk_version_at_least.3 ├── shtk_config_unset.3 ├── shtk_git_fetch.3 ├── shtk_unittest_set_expected_failure.3 ├── shtk_cli_warning.3 ├── shtk_unittest_add_test.3 ├── shtk_cli_info.3 ├── shtk_hw_ncpus.3 ├── shtk_unittest_skip.3 ├── shtk_cli_debug.3 ├── shtk_version.3 ├── shtk_unittest_fail.3 ├── shtk_cvs_update.3 ├── shtk_cli_log_level.3 ├── shtk_cli_error.3 ├── shtk_unittest_main.3 ├── shtk_cleanup_register.3 ├── shtk_cli_set_log_level.3 ├── shtk_cvs_checkout.3 ├── shtk_abort.3 ├── shtk_cvs_fetch.3 ├── shtk_cli_usage_error.3 ├── shtk_process_run.3 ├── shtk_fs_normalize_path.3 ├── shtk_bool_check.3 ├── shtk_cli_set_help_command.3 ├── shtk_config_load.3 ├── shtk_unittest_add_fixture.3 ├── shtk_config_override.3 └── shtk_config_run_hook.3 ├── COPYING ├── bool.subr ├── bootstrap.subr ├── list.subr ├── README.md ├── hw.subr ├── admin └── clean-all.sh ├── list_test.sh ├── hw_test.sh ├── bool_test.sh ├── shtk.m4 ├── configure.ac ├── git.subr ├── fs.subr ├── cleanup.subr ├── unittest └── operators.subr └── version.subr.in /site/CNAME: -------------------------------------------------------------------------------- 1 | shtk.jmmv.dev 2 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | * Julio Merino 2 | -------------------------------------------------------------------------------- /shtk.pc.in: -------------------------------------------------------------------------------- 1 | shtk_modulesdir=__SHTK_MODULESDIR__ 2 | shtk_tool=__SHTK_TOOL__ 3 | 4 | Name: shtk 5 | Description: Application toolkit for POSIX-compliant shell scripts 6 | Version: __SHTK_VERSION__ 7 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | pre-commit: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | - run: sudo apt-get install pre-commit 11 | - run: pre-commit run -a 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *_inttest 2 | *_inttest.log 3 | *_inttest.trs 4 | *_test 5 | *_test.log 6 | *_test.trs 7 | Makefile 8 | Makefile.in 9 | aclocal.m4 10 | admin/install-sh 11 | admin/missing 12 | admin/test-driver 13 | autom4te.cache 14 | config.log 15 | config.status 16 | configure 17 | configure~ 18 | man/shtk.1 19 | man/shtk_import.3 20 | shtk 21 | shtk.pc 22 | site/build 23 | site-out 24 | test-suite.log 25 | version.subr 26 | -------------------------------------------------------------------------------- /site/footer.html.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.4.0 4 | hooks: 5 | - id: check-case-conflict 6 | - id: check-executables-have-shebangs 7 | - id: check-merge-conflict 8 | - id: check-yaml 9 | - id: detect-private-key 10 | - id: end-of-file-fixer 11 | - id: trailing-whitespace 12 | - repo: https://github.com/jlebar/pre-commit-hooks.git 13 | rev: 62ca83ba4958da48ea44d9f24cd0aa58633376c7 14 | hooks: 15 | - id: do-not-submit 16 | -------------------------------------------------------------------------------- /.github/workflows/site.yml: -------------------------------------------------------------------------------- 1 | name: Deploy site 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | publish: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - run: sudo apt-get install -y mandoc pandoc 14 | - run: autoreconf -isv 15 | - run: ./configure 16 | - run: make site SITE_ID=238881e4-4c6d-4bcf-87df-d0fd12afd2ce 17 | - uses: JamesIves/github-pages-deploy-action@4.1.4 18 | with: 19 | folder: site-out 20 | repository-name: jmmv/shtk 21 | branch: gh-pages 22 | ssh-key: ${{ secrets.SHTK_SITE_DEPLOY_KEY }} 23 | -------------------------------------------------------------------------------- /site/styles.css: -------------------------------------------------------------------------------- 1 | table.head { 2 | border-style: solid; 3 | border-width: 0 0 1px 0; 4 | font-weight: bold; 5 | margin-bottom: 2em; 6 | width: 100%; 7 | } 8 | td.head-ltitle { 9 | text-align: left; 10 | } 11 | td.head-vol { 12 | text-align: center; 13 | } 14 | td.head-rtitle { 15 | text-align: right; 16 | } 17 | 18 | table.foot { 19 | border-style: solid; 20 | border-width: 1px 0 0 0; 21 | font-weight: bold; 22 | margin-top: 2em; 23 | width: 100%; 24 | } 25 | td.foot-date { 26 | text-align: left; 27 | } 28 | td.foot-os { 29 | text-align: right; 30 | } 31 | 32 | h1.Sh { 33 | margin-top: 1em; 34 | } 35 | a.permalink { 36 | text-transform: initial; 37 | text-decoration: none; 38 | } 39 | 40 | dl { 41 | margin-left: 1em; 42 | } 43 | dl dd { 44 | margin-left: 2em; 45 | } 46 | 47 | pre { 48 | padding: 1em; 49 | background: #eee; 50 | } 51 | -------------------------------------------------------------------------------- /man/README: -------------------------------------------------------------------------------- 1 | This directory contains the shtk API reference. The following conventions 2 | apply: 3 | 4 | * There shall be one shtk__(3) page per public function, 5 | describing the function's purpose, arguments and return values. 6 | 7 | * Each shtk__(3) page shall be linked from the 8 | corresponding shtk_(3) page and viceversa. 9 | 10 | * There shall be one shtk_(3) page per module, describing what 11 | the module is about. 12 | 13 | * All shtk_*(3) page shall link to shtk(3). 14 | 15 | * All shtk_(3) pages shall be linked from the shtk(3) page. 16 | 17 | * The base module is an exception and does not have an shtk_base(3) manual 18 | page. The reason for this is that base is loaded unconditionally so the 19 | user never knows that such module exists. 20 | 21 | These guidelines are intended to let the user navigate the documentation as 22 | follows: shtk(3) -> pick a module -> see shtk_(3) for all its 23 | functions -> pick a function -> see shtk__(3). 24 | -------------------------------------------------------------------------------- /site/index.html.frag: -------------------------------------------------------------------------------- 1 |

Shell Toolkit (shtk)

2 | 3 |

The Shell Toolkit, or shtk for short, is an application 4 | toolkit for programmers writing POSIX-compliant shell scripts.

5 | 6 |

shtk provides a collection of reusable modules that work 7 | on a wide variety of operating systems and shell interpreters. These modules 8 | are all ready to be used by calling the 9 | provided shtk_import primitive and 10 | "compiling" the shell scripts into their final form using 11 | the shtk(1) utility.

12 | 13 |

shtk is purely written in the shell scripting language so there 14 | are no dependencies to be installed.

15 | 16 |

shtk is known to be compatible with at least bash, dash, 17 | pdksh and zsh, and continuous integration tests prove this to be the 18 | case.

19 | 20 |

shtk is licensed under a liberal BSD 3-clause license and is 21 | brought to you by Julio 22 | Merino.

23 | 24 | Download shtk 26 | Read the shtk docs 27 | View on 28 | GitHub 29 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2012, 2013 Google Inc. 2 | Copyright 2023 Julio Merino. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of Google Inc. nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /site/docs.html.frag: -------------------------------------------------------------------------------- 1 |

Getting started

2 | 3 |

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.

4 | 5 |

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

6 | 7 |
 8 | shtk_import cli
 9 | 
10 | main() {
11 |     shtk_cli_info "Hello, world!"
12 | }
13 | 
14 | 15 |

Now, build and run it:

16 | 17 |
18 | $ shtk build hello.sh
19 | $ ./hello
20 | hello: I: Hello, world!
21 | 
22 | 23 |

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:

24 | 25 |
26 | shtk_import unittest
27 | 
28 | shtk_unittest_add_test hello_prints_hello_world_to_stderr
29 | hello_prints_hello_world_to_stderr_test() {
30 |     assert_command -e inline:"hello: I: Hello, world!\n" ../hello
31 | }
32 | 
33 | 34 |

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

35 | 36 |
37 | $ shtk build -m shtk_unittest_main hello_test.sh
38 | $ ./hello_test
39 | hello_test: I: Testing hello_prints_hello_world_to_stderr...
40 | Running checked command: ../hello
41 | hello_test: I: Testing hello_prints_hello_world_to_stderr... PASSED
42 | hello_test: I: Ran 1 tests; ALL PASSED
43 | 
44 | 45 |

Reference manual

46 | 47 |

The manual pages below correspond to shtk @SHTK_VERSION@.

48 | -------------------------------------------------------------------------------- /site/header.html.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Shell Toolkit (shtk) 7 | 8 | 9 | 10 | 11 | 12 | 33 | 34 |
35 |
36 |
37 | -------------------------------------------------------------------------------- /man/shtk_git.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2025 Julio Merino 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | .Dd January 6, 2025 26 | .Dt SHTK_GIT 3 27 | .Os 28 | .Sh NAME 29 | .Nm git 30 | .Nd Utilities to invoke Git and wrappers to simplify its operation 31 | .Sh LIBRARY 32 | shtk_import 33 | .Nm 34 | .Sh DESCRIPTION 35 | The 36 | .Nm 37 | module provides utilities to invoke the Git utility and to simplify its 38 | operation. 39 | .Sh SEE ALSO 40 | .Xr shtk 3 , 41 | .Xr shtk_git_clone 3 , 42 | .Xr shtk_git_fetch 3 , 43 | .Xr shtk_git_update 3 44 | .Sh HISTORY 45 | .Nm 46 | first appeared in 47 | .Nm shtk 48 | 1.8. 49 | -------------------------------------------------------------------------------- /man/shtk_process.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 7, 2014 29 | .Dt SHTK_PROCESS 3 30 | .Os 31 | .Sh NAME 32 | .Nm process 33 | .Nd Utilities to manipulate external processes 34 | .Sh LIBRARY 35 | shtk_import 36 | .Nm 37 | .Sh DESCRIPTION 38 | The 39 | .Nm 40 | module provides utilities to manipulate external processes. 41 | .Sh SEE ALSO 42 | .Xr shtk 3 , 43 | .Xr shtk_process_run 3 44 | .Sh HISTORY 45 | .Nm 46 | first appeared in 47 | .Nm shtk 48 | 1.0. 49 | -------------------------------------------------------------------------------- /bool.subr: -------------------------------------------------------------------------------- 1 | # Copyright 2013 Google Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google Inc. nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | shtk_import cli 30 | 31 | 32 | shtk_bool_check() { 33 | local value="${1}"; shift 34 | 35 | case "${value}" in 36 | [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) 37 | return 0 38 | ;; 39 | [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|0) 40 | return 1 41 | ;; 42 | *) 43 | [ "${#}" -ne 0 ] || set -- "Invalid boolean value '${value}'" 44 | shtk_cli_error "${@}" 45 | ;; 46 | esac 47 | } 48 | -------------------------------------------------------------------------------- /man/shtk_hw.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2017 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd February 6, 2017 29 | .Dt SHTK_HW 3 30 | .Os 31 | .Sh NAME 32 | .Nm hw 33 | .Nd Utilities to query details about the machine's hardware 34 | .Sh LIBRARY 35 | shtk_import 36 | .Nm 37 | .Sh DESCRIPTION 38 | The 39 | .Nm 40 | module provides utilities to query details about the machine's hardware. 41 | .Sh SEE ALSO 42 | .Xr shtk 3 , 43 | .Xr shtk_hw_ncpus 3 44 | .Sh HISTORY 45 | .Nm 46 | first appeared in 47 | .Nm shtk 48 | 1.7. 49 | -------------------------------------------------------------------------------- /man/shtk_cli_progname.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 5, 2014 29 | .Dt SHTK_CLI_PROGNAME 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cli_progname 33 | .Nd Gets the program name 34 | .Sh LIBRARY 35 | shtk_import cli 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Sh DESCRIPTION 39 | The 40 | .Nm 41 | function prints the basename of the currently-running script. 42 | .Sh SEE ALSO 43 | .Xr shtk 3 , 44 | .Xr shtk_cli 3 45 | .Sh HISTORY 46 | .Nm 47 | first appeared in 48 | .Nm shtk 49 | 1.0. 50 | -------------------------------------------------------------------------------- /man/shtk_fs.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd September 18, 2016 29 | .Dt SHTK_FS 3 30 | .Os 31 | .Sh NAME 32 | .Nm fs 33 | .Nd Utilities to manipulate file system paths 34 | .Sh LIBRARY 35 | shtk_import 36 | .Nm 37 | .Sh DESCRIPTION 38 | The 39 | .Nm 40 | module provides utilities to manipulate file system paths. 41 | .Sh SEE ALSO 42 | .Xr shtk 3 , 43 | .Xr shtk_fs_join_paths 3 , 44 | .Xr shtk_fs_normalize_path 3 45 | .Sh HISTORY 46 | .Nm 47 | first appeared in 48 | .Nm shtk 49 | 1.7. 50 | -------------------------------------------------------------------------------- /man/shtk_cli_dirname.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 5, 2014 29 | .Dt SHTK_CLI_DIRNAME 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cli_dirname 33 | .Nd Gets the directory where the current script lives 34 | .Sh LIBRARY 35 | shtk_import cli 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Sh DESCRIPTION 39 | The 40 | .Nm 41 | function prints the path to the directory where the current program lives. 42 | .Sh SEE ALSO 43 | .Xr shtk 3 , 44 | .Xr shtk_cli 3 45 | .Sh HISTORY 46 | .Nm 47 | first appeared in 48 | .Nm shtk 49 | 1.0. 50 | -------------------------------------------------------------------------------- /man/shtk_cleanup.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 5, 2014 29 | .Dt SHTK_CLEANUP 3 30 | .Os 31 | .Sh NAME 32 | .Nm cleanup 33 | .Nd Utilities to install exit handlers for cleanup routines 34 | .Sh LIBRARY 35 | shtk_import 36 | .Nm 37 | .Sh DESCRIPTION 38 | The 39 | .Nm 40 | module provides utilities to install exit handlers that perform various forms 41 | of cleanup at the end of the execution of the script. 42 | .Sh SEE ALSO 43 | .Xr shtk 3 , 44 | .Xr shtk_cleanup_register 3 45 | .Sh HISTORY 46 | .Nm 47 | first appeared in 48 | .Nm shtk 49 | 1.4. 50 | -------------------------------------------------------------------------------- /man/shtk_list.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 7, 2014 29 | .Dt SHTK_LIST 3 30 | .Os 31 | .Sh NAME 32 | .Nm list 33 | .Nd Utilities to manipulate lists 34 | .Sh LIBRARY 35 | shtk_import 36 | .Nm 37 | .Sh DESCRIPTION 38 | The 39 | .Nm 40 | module provides utilities to manipulate lists. 41 | A 42 | .Em list , 43 | in this context, is a collection of words separated by 44 | .Va IFS . 45 | .Sh SEE ALSO 46 | .Xr shtk 3 , 47 | .Xr shtk_list_contains 3 , 48 | .Xr shtk_list_filter 3 49 | .Sh HISTORY 50 | .Nm 51 | first appeared in 52 | .Nm shtk 53 | 1.0. 54 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | bash-nothing: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | - run: sudo apt-get install bash 11 | - run: sudo apt-get remove git 12 | - run: ./.github/workflows/build.sh bash "" 13 | 14 | bash-everything: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v4 18 | - run: sudo apt-get install bash cvs git 19 | - run: ./.github/workflows/build.sh bash "cvs git" 20 | 21 | dash-nothing: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@v4 25 | - run: sudo apt-get install dash 26 | - run: sudo apt-get remove git 27 | - run: ./.github/workflows/build.sh dash "" 28 | 29 | dash-everything: 30 | runs-on: ubuntu-latest 31 | steps: 32 | - uses: actions/checkout@v4 33 | - run: sudo apt-get install dash cvs git 34 | - run: ./.github/workflows/build.sh dash "cvs git" 35 | 36 | mksh-nothing: 37 | runs-on: ubuntu-latest 38 | steps: 39 | - uses: actions/checkout@v4 40 | - run: sudo apt-get install mksh 41 | - run: sudo apt-get remove git 42 | - run: ./.github/workflows/build.sh ksh "" 43 | 44 | mksh-everything: 45 | runs-on: ubuntu-latest 46 | steps: 47 | - uses: actions/checkout@v4 48 | - run: sudo apt-get install mksh cvs git 49 | - run: ./.github/workflows/build.sh ksh "cvs git" 50 | 51 | zsh-nothing: 52 | runs-on: ubuntu-latest 53 | steps: 54 | - uses: actions/checkout@v4 55 | - run: sudo apt-get install zsh 56 | - run: sudo apt-get remove git 57 | - run: ./.github/workflows/build.sh zsh "" 58 | 59 | zsh-everything: 60 | runs-on: ubuntu-latest 61 | steps: 62 | - uses: actions/checkout@v4 63 | - run: sudo apt-get install zsh cvs git 64 | - run: ./.github/workflows/build.sh zsh "cvs git" 65 | -------------------------------------------------------------------------------- /man/shtk_unittest_expect_equal.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 8, 2014 29 | .Dt SHTK_UNITTEST_EXPECT_EQUAL 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_expect_equal 33 | .Nd Non-fatal equality check between two values 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar name 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function is the non-fatal counterpart of 43 | .Xr shtk_unittest_assert_equal 3 . 44 | See the documentation of this other function for details. 45 | .Sh SEE ALSO 46 | .Xr shtk 3 , 47 | .Xr shtk_unittest 3 48 | .Sh HISTORY 49 | .Nm 50 | first appeared in 51 | .Nm shtk 52 | 1.6. 53 | -------------------------------------------------------------------------------- /man/shtk_unittest_expect_file.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 9, 2014 29 | .Dt SHTK_UNITTEST_EXPECT_FILE 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_expect_file 33 | .Nd Non-fatal check to validate the contents of a file 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar name 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function is the non-fatal counterpart of 43 | .Xr shtk_unittest_assert_file 3 . 44 | See the documentation of this other function for details. 45 | .Sh SEE ALSO 46 | .Xr shtk 3 , 47 | .Xr shtk_unittest 3 48 | .Sh HISTORY 49 | .Nm 50 | first appeared in 51 | .Nm shtk 52 | 1.6. 53 | -------------------------------------------------------------------------------- /man/shtk_unittest_expect_command.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 8, 2014 29 | .Dt SHTK_UNITTEST_EXPECT_COMMAND 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_expect_command 33 | .Nd Runs a command and validates its exit status and output 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar name 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function is the non-fatal counterpart of 43 | .Xr shtk_unittest_assert_command 3 . 44 | See the documentation of this other function for details. 45 | .Sh SEE ALSO 46 | .Xr shtk 3 , 47 | .Xr shtk_unittest 3 48 | .Sh HISTORY 49 | .Nm 50 | first appeared in 51 | .Nm shtk 52 | 1.6. 53 | -------------------------------------------------------------------------------- /man/shtk_unittest_expect_not_equal.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 8, 2014 29 | .Dt SHTK_UNITTEST_EXPECT_NOT_EQUAL 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_expect_not_equal 33 | .Nd Non-fatal inequality check between two values 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar name 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function is the non-fatal counterpart of 43 | .Xr shtk_unittest_assert_not_equal 3 . 44 | See the documentation of this other function for details. 45 | .Sh SEE ALSO 46 | .Xr shtk 3 , 47 | .Xr shtk_unittest 3 48 | .Sh HISTORY 49 | .Nm 50 | first appeared in 51 | .Nm shtk 52 | 1.6. 53 | -------------------------------------------------------------------------------- /bootstrap.subr: -------------------------------------------------------------------------------- 1 | #! %%SHTK_SH%% 2 | # Copyright 2012 Google Inc. 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # * Neither the name of Google Inc. nor the names of its contributors 15 | # may be used to endorse or promote products derived from this software 16 | # without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | # Script initialization code. 31 | # 32 | # The contents of this file get prepended to all the scripts generated by 33 | # "shtk build". As such, the contents in here should be as simple as 34 | # possible, should be able to detect problems during initialization and 35 | # cannot depend on other shtk code. 36 | 37 | : ${SHTK_MODULESDIR:=%%SHTK_MODULESDIR%%} 38 | 39 | if [ ! -f "${SHTK_MODULESDIR}/base.subr" ]; then 40 | echo "${0##*/}: E: Cannot open ${SHTK_MODULESDIR}/base.subr" 1>&2 41 | echo "${0##*/}: E: Does SHTK_MODULESDIR point to the right location?" 1>&2 42 | exit 1 43 | fi 44 | 45 | . "${SHTK_MODULESDIR}/base.subr" 46 | -------------------------------------------------------------------------------- /man/shtk_bool.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 5, 2014 29 | .Dt SHTK_BOOL 3 30 | .Os 31 | .Sh NAME 32 | .Nm bool 33 | .Nd Utilities to manipulate boolean values 34 | .Sh LIBRARY 35 | shtk_import 36 | .Nm 37 | .Sh DESCRIPTION 38 | The 39 | .Nm 40 | module provides utilities to manipulate boolean values. 41 | .Pp 42 | Remember that, in shell, truth is represented by 0 and falsehood is represented 43 | by non-0 values. 44 | This may come in as confusing if you are used to other programming languages, as 45 | it goes counter to all of them. 46 | .Sh SEE ALSO 47 | .Xr shtk 3 , 48 | .Xr shtk_bool_check 3 49 | .Sh HISTORY 50 | .Nm 51 | first appeared in 52 | .Nm shtk 53 | 1.4. 54 | -------------------------------------------------------------------------------- /list.subr: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Google Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google Inc. nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | 30 | shtk_list_contains() { 31 | local item="${1}"; shift 32 | 33 | while [ ${#} -gt 0 ]; do 34 | [ "${1}" != "${item}" ] || return 0 35 | shift 36 | done 37 | return 1 38 | } 39 | 40 | 41 | shtk_list_filter() { 42 | local pattern="${1}"; shift 43 | 44 | local found_any=no 45 | for arg in "${@}"; do 46 | local found=no 47 | eval "case \"${arg}\" in ${pattern}) found=yes ;; esac" 48 | if [ "${found}" = yes ]; then 49 | if [ "${found_any}" = yes ]; then 50 | printf " ${arg}" 51 | else 52 | printf "${arg}" 53 | found_any=yes 54 | fi 55 | fi 56 | done 57 | [ "${found_any}" = no ] || echo 58 | } 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | The Shell Toolkit 2 | ================= 3 | 4 | The Shell Toolkit, or shtk for short, is an **application toolkit** 5 | for programmers writing POSIX-compliant shell scripts. 6 | 7 | shtk provides a **collection of reusable modules** that work on a wide 8 | variety of operating systems and shell interpreters. These modules are all 9 | ready to be used by calling the provided `shtk_import` primitive and 10 | "compiling" the shell scripts into their final form using the `shtk(1)` 11 | utility. 12 | 13 | shtk is purely written in the shell scripting language so there are **no 14 | dependencies** to be installed. 15 | 16 | shtk is **known to be compatible with at least bash, dash, pdksh and zsh**, 17 | and continuous integration tests prove this to be the case. 18 | 19 | shtk is licensed under a **[liberal BSD 3-clause license](LICENSE)**. 20 | 21 | 22 | Download 23 | -------- 24 | 25 | The latest version of shtk is 1.7 and was released on February 17th, 2017. 26 | 27 | Download: [sthk-1.7](../../releases/tag/shtk-1.7). 28 | 29 | See the [release notes](NEWS.md) for information about the changes in this 30 | and all previous releases. 31 | 32 | 33 | Installation 34 | ------------ 35 | 36 | You are encouraged to install binary packages for your operating system 37 | wherever available: 38 | 39 | * FreeBSD 10.0 and above: install the `shtk` package with `pkg install 40 | shtk`. 41 | 42 | * NetBSD with pkgsrc: install the `pkgsrc/devel/shtk` package. 43 | 44 | Should you want to build and install shtk from the source tree provided in 45 | this repository, follow the instructions in the 46 | [INSTALL.md file](INSTALL.md). 47 | 48 | 49 | Documentation 50 | ------------- 51 | 52 | shtk is fully documented in manual pages, all of which are stored in the 53 | [`man`](man) subdirectory. Once you have built and installed `shtk`, 54 | simply type `man 1 shtk` to open the manual page for the `shtk` 55 | command-line utility and type `man 3 shtk` to open the introductory page to 56 | the API reference manual. The `SEE ALSO` sections will guide you through 57 | the rest of the documentation. 58 | 59 | You can access pre-built versions of the documentation online by visiting: 60 | 61 | > 62 | 63 | 64 | Support 65 | ------- 66 | 67 | Please use the 68 | [shtk-discuss mailing list](https://groups.google.com/forum/#!forum/shtk-discuss) 69 | for any support inquiries. 70 | -------------------------------------------------------------------------------- /man/shtk_cli.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd June 11, 2017 29 | .Dt SHTK_CLI 3 30 | .Os 31 | .Sh NAME 32 | .Nm cli 33 | .Nd Utilities to implement command-line interfaces 34 | .Sh LIBRARY 35 | shtk_import 36 | .Nm 37 | .Sh DESCRIPTION 38 | The 39 | .Nm 40 | module provides utilities to implement consistent and user-friendly 41 | command-line interfaces. 42 | .Sh SEE ALSO 43 | .Xr shtk 3 , 44 | .Xr shtk_cli_debug 3 , 45 | .Xr shtk_cli_dirname 3 , 46 | .Xr shtk_cli_error 3 , 47 | .Xr shtk_cli_info 3 , 48 | .Xr shtk_cli_log_level 3 , 49 | .Xr shtk_cli_progname 3 , 50 | .Xr shtk_cli_set_help_command 3 , 51 | .Xr shtk_cli_set_log_level 3 , 52 | .Xr shtk_cli_usage_error 3 , 53 | .Xr shtk_cli_warning 3 54 | .Sh HISTORY 55 | .Nm 56 | first appeared in 57 | .Nm shtk 58 | 1.0. 59 | -------------------------------------------------------------------------------- /man/shtk_git_update.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2025 Julio Merino 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | .Dd January 6, 2025 26 | .Dt SHTK_GIT_UPDATE 3 27 | .Os 28 | .Sh NAME 29 | .Nm shtk_git_update 30 | .Nd Updates an existing working copy of a Git repository 31 | .Sh LIBRARY 32 | shtk_import git 33 | .Sh SYNOPSIS 34 | .Nm 35 | .Ar branch 36 | .Ar directory 37 | .Sh DESCRIPTION 38 | The 39 | .Nm 40 | function updates the existing working copy in 41 | .Ar directory 42 | to 43 | .Ar branch . 44 | .Pp 45 | In general, you should resort to using the higher-level 46 | .Xr shtk_git_fetch 3 47 | wrapper as it properly handles the case of missing working copies. 48 | .Sh EXAMPLES 49 | .Bd -literal -offset indent 50 | shtk_git_update master /usr/src 51 | .Ed 52 | .Sh ERRORS 53 | .Nm 54 | aborts execution with an error if the given 55 | .Ar directory 56 | does not yet exist or if the Git update operation fails. 57 | .Sh SEE ALSO 58 | .Xr shtk 3 , 59 | .Xr shtk_git 3 60 | .Sh HISTORY 61 | .Nm 62 | first appeared in 63 | .Nm shtk 64 | 1.8. 65 | -------------------------------------------------------------------------------- /man/shtk_config_get.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 6, 2014 29 | .Dt SHTK_CONFIG_GET 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_config_get 33 | .Nd Gets the value of a defined configuration variable 34 | .Sh LIBRARY 35 | shtk_import config 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar var_name 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function prints to stdout the value of the configuration variable 43 | .Ar var_name . 44 | The variable must have been previously set by a call to 45 | .Xr shtk_config_set 3 46 | within the script or by the user in the configuration file. 47 | .Sh ERRORS 48 | If the variable has not been previously set, then execution terminates with 49 | an error. 50 | .Sh SEE ALSO 51 | .Xr shtk 3 , 52 | .Xr shtk_config 3 53 | .Sh HISTORY 54 | .Nm 55 | first appeared in 56 | .Nm shtk 57 | 1.0. 58 | -------------------------------------------------------------------------------- /man/shtk_config_get_bool.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 6, 2014 29 | .Dt SHTK_CONFIG_GET_BOOL 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_config_get_bool 33 | .Nd Gets the value of a boolean configuration variable 34 | .Sh LIBRARY 35 | shtk_import config 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar var_name 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function gets the value of the configuration variable 43 | .Ar var_name , 44 | interpreting its contents as a boolean as described in 45 | .Xr shtk_bool_check 3 . 46 | .Sh RETURN VALUES 47 | Returns 0 (true) if the variable is set to a truth value; otherwise, including 48 | the case where the variable has not been set, returns 1. 49 | .Sh SEE ALSO 50 | .Xr shtk 3 , 51 | .Xr shtk_config 3 52 | .Sh HISTORY 53 | .Nm 54 | first appeared in 55 | .Nm shtk 56 | 1.0. 57 | -------------------------------------------------------------------------------- /man/shtk_unittest_assert_equal.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 8, 2014 29 | .Dt SHTK_UNITTEST_ASSERT_EQUAL 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_assert_equal 33 | .Nd Fatal equality check between two values 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar expected_value 39 | .Ar actual_value 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function implements an equality check between two values. 44 | If 45 | .Ar actual_value 46 | matches the expected value given in 47 | .Ar expected_value 48 | (usually hardcoded in the test), then the check is considered a success. 49 | Otherwise, the check fails and the test case is aborted. 50 | .Sh SEE ALSO 51 | .Xr shtk 3 , 52 | .Xr shtk_unittest 3 53 | .Sh HISTORY 54 | .Nm 55 | first appeared in 56 | .Nm shtk 57 | 1.6. 58 | -------------------------------------------------------------------------------- /man/shtk_list_contains.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 7, 2014 29 | .Dt SHTK_LIST_CONTAINS 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_list_contains 33 | .Nd Checks if an item appears in a list 34 | .Sh LIBRARY 35 | shtk_import list 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar item 39 | .Op Ar list_value1 .. list_valueN 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function searches for 44 | .Ar item 45 | in the list provided by the arguments 46 | .Ar list_value1 47 | to 48 | .Ar list_valueN . 49 | Each list value must be provided as a separate positional parameter. 50 | .Sh RETURN VALUES 51 | .Nm 52 | returns 0 (true) if 53 | .Ar item 54 | appears in the list and 1 (false) if it does not. 55 | .Sh SEE ALSO 56 | .Xr shtk 3 , 57 | .Xr shtk_list 3 58 | .Sh HISTORY 59 | .Nm 60 | first appeared in 61 | .Nm shtk 62 | 1.0. 63 | -------------------------------------------------------------------------------- /man/shtk_cvs.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 7, 2014 29 | .Dt SHTK_CVS 3 30 | .Os 31 | .Sh NAME 32 | .Nm cvs 33 | .Nd Utilities to invoke CVS and wrappers to simplify its operation 34 | .Sh LIBRARY 35 | shtk_import 36 | .Nm 37 | .Sh DESCRIPTION 38 | The 39 | .Nm 40 | module provides utilities to invoke the CVS utility and to simplify its 41 | operation. 42 | .Sh SEE ALSO 43 | .Xr shtk 3 , 44 | .Xr shtk_cvs_checkout 3 , 45 | .Xr shtk_cvs_fetch 3 , 46 | .Xr shtk_cvs_update 3 47 | .Sh HISTORY 48 | .Nm 49 | first appeared in 50 | .Nm shtk 51 | 1.0. 52 | .Pp 53 | .Nm 54 | was originally designed to support 55 | .Xr sysbuild 1 , 56 | a tool to automate 57 | .Nx 58 | system builds. 59 | However, because CVS is an obsolete version control system not in widespread 60 | use any longer, this module is of limited use. 61 | -------------------------------------------------------------------------------- /man/shtk_config_include.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 6, 2014 29 | .Dt SHTK_CONFIG_INCLUDE 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_config_include 33 | .Nd Includes a file within a configuration file 34 | .Sh LIBRARY 35 | shtk_import config 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar file 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function includes the file given in 43 | .Ar file 44 | within a configuration file. 45 | The path in 46 | .Ar file 47 | can be relative, and in such case the path is resolved using the directory of 48 | the configuration file being loaded as the 49 | .Dq current directory . 50 | .Pp 51 | .Em This function is supposed to be used only within configuration files . 52 | .Sh SEE ALSO 53 | .Xr shtk 3 , 54 | .Xr shtk_config 3 55 | .Sh HISTORY 56 | .Nm 57 | first appeared in 58 | .Nm shtk 59 | 1.6. 60 | -------------------------------------------------------------------------------- /man/shtk_unittest_assert_not_equal.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 8, 2014 29 | .Dt SHTK_UNITTEST_ASSERT_NOT_EQUAL 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_assert_not_equal 33 | .Nd Fatal inequality check between two values 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar unexpected_value 39 | .Ar actual_value 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function implements an inequality check between two values. 44 | If 45 | .Ar actual_value 46 | does not match the value given in 47 | .Ar unexpected_value 48 | (usually hardcoded in the test), then the check is considered a success. 49 | Otherwise, the check fails and the test case is aborted. 50 | .Sh SEE ALSO 51 | .Xr shtk 3 , 52 | .Xr shtk_unittest 3 53 | .Sh HISTORY 54 | .Nm 55 | first appeared in 56 | .Nm shtk 57 | 1.6. 58 | -------------------------------------------------------------------------------- /man/shtk_config_get_default.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 6, 2014 29 | .Dt SHTK_CONFIG_GET_DEFAULT 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_config_get_default 33 | .Nd Gets the value of a possibly-unset configuration variable 34 | .Sh LIBRARY 35 | shtk_import config 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar var_name 39 | .Ar default_value 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function prints to stdout the value of the configuration variable 44 | .Ar var_name 45 | if it has been previously set by a call to 46 | .Xr shtk_config_set 3 47 | within the script or by the user in the configuration file. 48 | Otherwise, if the variable has not been set, the printed value is 49 | .Ar default_value . 50 | .Sh SEE ALSO 51 | .Xr shtk 3 , 52 | .Xr shtk_config 3 53 | .Sh HISTORY 54 | .Nm 55 | first appeared in 56 | .Nm shtk 57 | 1.0. 58 | -------------------------------------------------------------------------------- /man/shtk_config_init.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 6, 2014 29 | .Dt SHTK_CONFIG_INIT 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_config_init 33 | .Nd Initializes the configuration module 34 | .Sh LIBRARY 35 | shtk_import config 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar var_name1 39 | .Op Ar .. var_nameN 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function initializes the configuration module and prepares it to load 44 | a configuration file that may define any of the configuration variables 45 | provided by 46 | .Ar var_name1 47 | to 48 | .Ar var_nameN . 49 | .Pp 50 | Only the variable names provided in the call to 51 | .Nm 52 | will be recognized when loading a configuration file with 53 | .Xr shtk_config_load 3 . 54 | .Sh SEE ALSO 55 | .Xr shtk 3 , 56 | .Xr shtk_config 3 57 | .Sh HISTORY 58 | .Nm 59 | first appeared in 60 | .Nm shtk 61 | 1.0. 62 | -------------------------------------------------------------------------------- /man/shtk_version_is.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 7, 2014 29 | .Dt SHTK_VERSION_IS 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_version_is 33 | .Nd Checks if shtk is a specific version 34 | .Sh LIBRARY 35 | shtk_import version 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar version 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function checks if the version of the in-use 43 | .Nm shtk 44 | is exactly 45 | .Ar version . 46 | .Sh RETURN VALUES 47 | .Nm 48 | returns 0 (true) if the in-use 49 | .Nm shtk 50 | is version 51 | .Ar version ; 52 | 1 (false) otherwise. 53 | .Sh EXAMPLES 54 | .Bd -literal -offset indent 55 | if shtk_version_is 1.8; then 56 | # Test for a known bug, for example, and work it around. 57 | fi 58 | .Ed 59 | .Sh SEE ALSO 60 | .Xr shtk 3 , 61 | .Xr shtk_version 3 62 | .Sh HISTORY 63 | .Nm 64 | first appeared in 65 | .Nm shtk 66 | 1.5. 67 | -------------------------------------------------------------------------------- /hw.subr: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google Inc. nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | 30 | # Overrides the number of CPUs returned by shtk_nw_ncpus if set to non-zero. 31 | : ${SHTK_HW_NCPUS:=0} 32 | 33 | 34 | shtk_hw_ncpus() { 35 | if [ "${SHTK_HW_NCPUS}" -gt 0 ]; then 36 | echo "${SHTK_HW_NCPUS}" 37 | return 0 38 | fi 39 | 40 | local ncpus=0 41 | case "$(uname -s)" in 42 | Darwin) 43 | ncpus="$(/usr/sbin/sysctl -n hw.ncpu)" || true 44 | ;; 45 | FreeBSD) 46 | ncpus="$(/sbin/sysctl -n hw.ncpu)" || true 47 | ;; 48 | Linux) 49 | ncpus="$(grep '^processor[ ]*:' /proc/cpuinfo \ 50 | | wc -l | awk '{print $1}')" || true 51 | ;; 52 | NetBSD) 53 | ncpus="$(/sbin/sysctl -n hw.ncpuonline)" || true 54 | ;; 55 | esac 56 | [ "${ncpus}" -gt 1 ] || ncpus=1 57 | echo "${ncpus}" 58 | } 59 | -------------------------------------------------------------------------------- /man/shtk_fs_join_paths.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2016 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd September 18, 2016 29 | .Dt SHTK_FS_JOIN_PATHS 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_fs_join_paths 33 | .Nd Concatenates a series of path entries 34 | .Sh LIBRARY 35 | shtk_import fs 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar path1 39 | .Op Ar .. pathN 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function takes a collection of path components and concatenates them, 44 | printing the result to stdout. 45 | .Pp 46 | The resulting path is normalized according to the rules described in 47 | .Xr shtk_fs_normalize_path 3 . 48 | .Sh RETURN VALUES 49 | .Nm 50 | returns 0. 51 | .Sh EXAMPLES 52 | .Bd -literal -offset indent 53 | shtk_fs_join_paths foo//bar /baz/. # Prints ./foo/bar/baz 54 | shtk_fs_join_paths /bin ls # Prints /bin/ls 55 | .Ed 56 | .Sh SEE ALSO 57 | .Xr shtk 3 , 58 | .Xr shtk_fs 3 59 | .Sh HISTORY 60 | .Nm 61 | first appeared in 62 | .Nm shtk 63 | 1.7. 64 | -------------------------------------------------------------------------------- /man/shtk_version_at_most.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 7, 2014 29 | .Dt SHTK_VERSION_AT_MOST 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_version_at_most 33 | .Nd Checks if shtk is a maximum version 34 | .Sh LIBRARY 35 | shtk_import version 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar version 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function checks if the version of the in-use 43 | .Nm shtk 44 | is, at most, the version given in 45 | .Ar version . 46 | .Sh RETURN VALUES 47 | .Nm 48 | returns 0 (true) if the in-use 49 | .Nm shtk 50 | is version 51 | .Ar version 52 | or earlier; 1 (false) otherwise. 53 | .Sh EXAMPLES 54 | .Bd -literal -offset indent 55 | if shtk_version_at_most 1.10; then 56 | # Maybe exit if we know we do not work well with 1.10 and above. 57 | fi 58 | .Ed 59 | .Sh SEE ALSO 60 | .Xr shtk 3 , 61 | .Xr shtk_version 3 62 | .Sh HISTORY 63 | .Nm 64 | first appeared in 65 | .Nm shtk 66 | 1.5. 67 | -------------------------------------------------------------------------------- /man/shtk_git_clone.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2025 Julio Merino 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | .Dd January 6, 2025 26 | .Dt SHTK_GIT_CLONE 3 27 | .Os 28 | .Sh NAME 29 | .Nm shtk_git_clone 30 | .Nd Checks out a new working copy out of a Git repository 31 | .Sh LIBRARY 32 | shtk_import git 33 | .Sh SYNOPSIS 34 | .Nm 35 | .Ar repo 36 | .Ar branch 37 | .Ar directory 38 | .Sh DESCRIPTION 39 | The 40 | .Nm 41 | function checks out a new working copy of the repository 42 | .Ar repo 43 | into 44 | .Ar directory 45 | using the given 46 | .Ar branch . 47 | The 48 | .Ar directory 49 | must not exist. 50 | .Pp 51 | In general, you should resort to using the higher-level 52 | .Xr shtk_git_fetch 3 53 | wrapper as it properly handles the case of already existing working 54 | copies. 55 | .Sh EXAMPLES 56 | .Bd -literal -offset indent 57 | shtk_git_clone https://example.com/repo.git master /usr/src 58 | .Ed 59 | .Sh ERRORS 60 | .Nm 61 | aborts execution with an error if the given 62 | .Ar directory 63 | already exists or if the Git clone operation fails. 64 | .Sh SEE ALSO 65 | .Xr shtk 3 , 66 | .Xr shtk_git 3 67 | .Sh HISTORY 68 | .Nm 69 | first appeared in 70 | .Nm shtk 71 | 1.8. 72 | -------------------------------------------------------------------------------- /man/shtk_config_set.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 6, 2014 29 | .Dt SHTK_CONFIG_SET 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_config_set 33 | .Nd Sets the value of a configuration variable 34 | .Sh LIBRARY 35 | shtk_import config 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar var_name 39 | .Ar value 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function sets the value of the configuration variable 44 | .Ar var_name 45 | to 46 | .Ar value . 47 | The given configuration variable must be a valid configuration variable as 48 | previously specified by a call to 49 | .Xr shtk_config_init 3 . 50 | .Sh ERRORS 51 | If 52 | .Ar var_name 53 | is invalid because it has not been registered as a valid configuration variable 54 | with a call to 55 | .Xr shtk_config_init 3 , 56 | execution terminates with an error. 57 | .Sh SEE ALSO 58 | .Xr shtk 3 , 59 | .Xr shtk_config 3 60 | .Sh HISTORY 61 | .Nm 62 | first appeared in 63 | .Nm shtk 64 | 1.0. 65 | -------------------------------------------------------------------------------- /admin/clean-all.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Copyright 2010 Google Inc. 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # * Neither the name of Google Inc. nor the names of its contributors 15 | # may be used to endorse or promote products derived from this software 16 | # without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | Prog_Name=${0##*/} 31 | 32 | if [ ! -f ./shtk.sh ]; then 33 | echo "${Prog_Name}: must be run from the source top directory" 1>&2 34 | exit 1 35 | fi 36 | 37 | if [ ! -f configure ]; then 38 | echo "${Prog_Name}: configure not found; nothing to clean?" 1>&2 39 | exit 1 40 | fi 41 | 42 | [ -f Makefile ] || ./configure 43 | make distclean 44 | 45 | # Top-level directory. 46 | rm -f Makefile.in 47 | rm -f aclocal.m4 48 | rm -rf autom4te.cache 49 | rm -f configure 50 | rm -f shtk-*.tar.gz 51 | 52 | # admin directory. 53 | rm -f admin/install-sh 54 | rm -f admin/missing 55 | 56 | # Files and directories spread all around the tree. 57 | find . -name '#*' | xargs rm -rf 58 | find . -name '*~' | xargs rm -rf 59 | 60 | # Show remaining files. 61 | if [ -n "${GIT}" ]; then 62 | echo ">>> untracked and ignored files" 63 | "${GIT}" status --porcelain --ignored | grep -E '^(\?\?|!!)' || true 64 | fi 65 | -------------------------------------------------------------------------------- /man/shtk_config_has.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 6, 2014 29 | .Dt SHTK_CONFIG_HAS 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_config_has 33 | .Nd Checks if a configuration variable is set 34 | .Sh LIBRARY 35 | shtk_import config 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar var_name 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function checks if the configuration variable 43 | .Ar var_name 44 | has been previously set by a call to 45 | .Xr shtk_config_set 3 46 | within the script or by the user in the configuration file. 47 | .Pp 48 | Note that 49 | .Nm 50 | properly distinguishes the case between a variable that has never been 51 | defined and a variable that has been defined to the empty value. 52 | .Sh RETURN VALUES 53 | Returns 0 (true) if 54 | .Va var_name 55 | has been defined; 1 (false) otherwise. 56 | .Sh SEE ALSO 57 | .Xr shtk 3 , 58 | .Xr shtk_config 3 59 | .Sh HISTORY 60 | .Nm 61 | first appeared in 62 | .Nm shtk 63 | 1.0. 64 | -------------------------------------------------------------------------------- /man/shtk_list_filter.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 7, 2014 29 | .Dt SHTK_LIST_FILTER 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_list_filter 33 | .Nd Filters the elements of a list based on a pattern 34 | .Sh LIBRARY 35 | shtk_import list 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar pattern 39 | .Op Ar list_value1 .. list_valueN 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function selects and returns the elements of the list provided by the arguments 44 | .Ar list_value1 45 | to 46 | .Ar list_valueN 47 | if the match the given shell 48 | .Ar pattern . 49 | Each list value must be provided as a separate positional parameter. 50 | .Sh EXAMPLES 51 | .Bd -literal -offset indent 52 | original="foo foobar baz frobz" 53 | filtered="$(shtk_list_filter 'foo*' ${original})" 54 | echo "Results: ${filtered}" 55 | .Ed 56 | .Sh SEE ALSO 57 | .Xr shtk 3 , 58 | .Xr shtk_list 3 59 | .Sh HISTORY 60 | .Nm 61 | first appeared in 62 | .Nm shtk 63 | 1.0. 64 | -------------------------------------------------------------------------------- /man/shtk_unittest_delayed_fail.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 8, 2014 29 | .Dt SHTK_UNITTEST_DELAYED_FAIL 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_delayed_fail 33 | .Nd Records a delayed failure 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Op Ar arg1 .. argN 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function marks the currently running test case as failed but allows the 43 | test to continue execution. 44 | The message given in the arguments 45 | .Ar arg1 46 | through 47 | .Ar argN 48 | is printed along the failure. 49 | .Pp 50 | .Nm 51 | should be used to fail the test case when an erroneous condition is 52 | detected and such condition does not prevent the rest of the test case's 53 | code from running and possibly raising other (legitimate) failure signals. 54 | .Sh SEE ALSO 55 | .Xr shtk 3 , 56 | .Xr shtk_unittest 3 57 | .Sh HISTORY 58 | .Nm 59 | first appeared in 60 | .Nm shtk 61 | 1.6. 62 | -------------------------------------------------------------------------------- /man/shtk_version_at_least.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 7, 2014 29 | .Dt SHTK_VERSION_AT_LEAST 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_version_at_least 33 | .Nd Checks if shtk is a minimum version 34 | .Sh LIBRARY 35 | shtk_import version 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar version 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function checks if the version of the in-use 43 | .Nm shtk 44 | is, at least, the version given in 45 | .Ar version . 46 | .Sh RETURN VALUES 47 | .Nm 48 | returns 0 (true) if the in-use 49 | .Nm shtk 50 | is version 51 | .Ar version 52 | or later; 1 (false) otherwise. 53 | .Sh EXAMPLES 54 | .Bd -literal -offset indent 55 | if shtk_version_at_least 1.5; then 56 | # Use symbols that are available in 1.5 and later. 57 | else 58 | # Workaround the lack of functionality in shtk, or exit. 59 | fi 60 | .Ed 61 | .Sh SEE ALSO 62 | .Xr shtk 3 , 63 | .Xr shtk_version 3 64 | .Sh HISTORY 65 | .Nm 66 | first appeared in 67 | .Nm shtk 68 | 1.5. 69 | -------------------------------------------------------------------------------- /man/shtk_config_unset.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 6, 2014 29 | .Dt SHTK_CONFIG_UNSET 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_config_unset 33 | .Nd Clears a configuration variable 34 | .Sh LIBRARY 35 | shtk_import config 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar var_name 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function unsets the value of the configuration variable 43 | .Ar var_name . 44 | It is OK to call 45 | .Nm 46 | even if 47 | .Ar var_name 48 | has never been previously set. 49 | However, the given configuration variable must be a valid configuration variable 50 | as previously specified by a call to 51 | .Xr shtk_config_init 3 . 52 | .Sh ERRORS 53 | If 54 | .Ar var_name 55 | is invalid because it has not been registered as a valid configuration variable 56 | with a call to 57 | .Xr shtk_config_init 3 , 58 | execution terminates with an error. 59 | .Sh SEE ALSO 60 | .Xr shtk 3 , 61 | .Xr shtk_config 3 62 | .Sh HISTORY 63 | .Nm 64 | first appeared in 65 | .Nm shtk 66 | 1.0. 67 | -------------------------------------------------------------------------------- /man/shtk_git_fetch.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2025 Julio Merino 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | .Dd January 6, 2025 26 | .Dt SHTK_GIT_FETCH 3 27 | .Os 28 | .Sh NAME 29 | .Nm shtk_git_fetch 30 | .Nd Checks out or updates a Git working copy 31 | .Sh LIBRARY 32 | shtk_import git 33 | .Sh SYNOPSIS 34 | .Nm 35 | .Ar repo 36 | .Ar branch 37 | .Ar directory 38 | .Sh DESCRIPTION 39 | The 40 | .Nm 41 | function is a simple wrapper over the lower-level 42 | .Xr shtk_git_checkout 3 43 | and 44 | .Xr shtk_git_update 3 45 | functions, using one or the other depending on the status of the local 46 | working copy. 47 | .Pp 48 | More specifically: if 49 | .Ar directory 50 | does not yet exist or it is empty, the 51 | .Nm 52 | function checks out a new working copy of the repository 53 | .Ar repo 54 | into it using the given 55 | .Ar branch . 56 | If 57 | .Ar directory 58 | does exist and contains a 59 | .Pa Git 60 | control directory, then the 61 | .Nm 62 | function performs a working copy update of the repository using the given 63 | .Ar branch . 64 | .Sh EXAMPLES 65 | .Bd -literal -offset indent 66 | shtk_git_fetch https://example.com/repo.git master /usr/src 67 | .Ed 68 | .Sh SEE ALSO 69 | .Xr shtk 3 , 70 | .Xr shtk_git 3 71 | .Sh HISTORY 72 | .Nm 73 | first appeared in 74 | .Nm shtk 75 | 1.8. 76 | -------------------------------------------------------------------------------- /list_test.sh: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Google Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google Inc. nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | shtk_import list 30 | shtk_import unittest 31 | 32 | 33 | shtk_unittest_add_test contains__yes 34 | contains__yes_test() { 35 | items="bar foo baz" 36 | shtk_list_contains foo ${items} || fail "Element not found in list" 37 | } 38 | 39 | 40 | shtk_unittest_add_test contains__no 41 | contains__no_test() { 42 | items="bar foo baz" 43 | shtk_list_contains fo ${items} && fail "Element found in list" 44 | } 45 | 46 | 47 | shtk_unittest_add_test filter__no_items 48 | filter__no_items_test() { 49 | expect_equal "" "$(shtk_list_filter '*')" 50 | } 51 | 52 | 53 | shtk_unittest_add_test filter__no_results 54 | filter__no_results_test() { 55 | items="abc a1 foo a2 a3 bar" 56 | expect_equal "" "$(shtk_list_filter '*a' ${items})" 57 | } 58 | 59 | 60 | shtk_unittest_add_test filter__some_results 61 | filter__some_results_test() { 62 | items="abc a1 foo a2 a3 bar" 63 | expect_equal "a1 a2 a3" "$(shtk_list_filter 'a[0-9]*' ${items})" 64 | expect_equal "foo a3" "$(shtk_list_filter 'a3|foo' ${items})" 65 | } 66 | -------------------------------------------------------------------------------- /hw_test.sh: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google Inc. nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | shtk_import hw 30 | shtk_import unittest 31 | 32 | 33 | shtk_unittest_add_test ncpus__real 34 | ncpus__real_test() { 35 | local exp_ncpus= 36 | if [ -f /proc/cpuinfo ]; then 37 | exp_ncpus="$(grep '^processor[ ]*:' /proc/cpuinfo \ 38 | | wc -l | awk '{print $1}')" 39 | fi 40 | for var in hw.ncpuonline hw.ncpu; do 41 | if [ -z "${exp_ncpus}" ]; then 42 | exp_ncpus="$(sysctl -n "${var}")" || true 43 | fi 44 | done 45 | if [ -z "${exp_ncpus}" ]; then 46 | exp_ncpus=1 47 | fi 48 | echo assert_equal "${exp_ncpus}" "$(shtk_hw_ncpus)" 49 | assert_equal "${exp_ncpus}" "$(shtk_hw_ncpus)" 50 | } 51 | 52 | 53 | shtk_unittest_add_test ncpus__injected 54 | ncpus__injected_test() { 55 | export SHTK_HW_NCPUS=100 56 | assert_equal 100 "$(shtk_hw_ncpus)" 57 | 58 | # Invalid mock values should be ignored. 59 | for invalid_value in '' 0 -5 invalid; do 60 | export SHTK_HW_NCPUS="${invalid_value}" 61 | ncpus__real_test 62 | done 63 | } 64 | -------------------------------------------------------------------------------- /man/shtk_unittest_set_expected_failure.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 8, 2014 29 | .Dt SHTK_UNITTEST_SET_EXPECT_FAILURE 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_set_expect_failure 33 | .Nd Makes the test expect a failure 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Sh DESCRIPTION 39 | The 40 | .Nm 41 | function changes the behavior of the test so that a failure indicates 42 | success and a pass indicates a failure. 43 | .Pp 44 | Changing the expectation of the test to a failure is useful for test 45 | cases that exercise a known bug: while the bug is live, the test case 46 | will pass with a message describing the error encountered; however, 47 | when the bug is fixed, the test will start failing indicating that it 48 | needs to be revised. 49 | .Pp 50 | .Nm 51 | can only be called once during the execution of a test case and its 52 | effects cannot be reversed. 53 | .Sh SEE ALSO 54 | .Xr shtk 3 , 55 | .Xr shtk_unittest 3 56 | .Sh HISTORY 57 | .Nm 58 | first appeared in 59 | .Nm shtk 60 | 1.6. 61 | -------------------------------------------------------------------------------- /man/shtk_cli_warning.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 5, 2014 29 | .Dt SHTK_CLI_WARNING 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cli_warning 33 | .Nd Prints a warning message 34 | .Sh LIBRARY 35 | shtk_import cli 36 | .Sh SYNOPSIS 37 | .Nm shtk_cli_warning 38 | .Ar message1 39 | .Op Ar .. messageN 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function prints the given warning message to stderr. 44 | The message can be provided as one or more arguments as depicted by 45 | .Ar message1 46 | to 47 | .Ar messageN ; 48 | all arguments are concatenated together into a single line. 49 | .Pp 50 | The printed message has the following form, where 51 | .Sq progname 52 | is determined by 53 | .Xr shtk_cli_progname 3 : 54 | .Bd -literal -offset indent 55 | progname: W: message1 .. messageN 56 | .Ed 57 | .Pp 58 | .Nm 59 | should be used to inform the user of erroneous but non-critical conditions that 60 | permit the script to continue execution. 61 | .Sh SEE ALSO 62 | .Xr shtk 3 , 63 | .Xr shtk_cli 3 64 | .Sh HISTORY 65 | .Nm 66 | first appeared in 67 | .Nm shtk 68 | 1.0. 69 | -------------------------------------------------------------------------------- /man/shtk_unittest_add_test.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 8, 2014 29 | .Dt SHTK_UNITTEST_ADD_TEST 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_add_test 33 | .Nd Defines a standalone test case 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar name 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function registers the standalone test case given by 43 | .Ar name . 44 | A function named 45 | .Sq \*(Ltname\*(Gt_test 46 | must be defined 47 | .Em after 48 | the call to 49 | .Nm 50 | has been made. 51 | .Sh EXAMPLES 52 | The following piece of code illustrates the definition of a couple of 53 | test cases: 54 | .Bd -literal -offset indent 55 | shtk_unittest_add_test first_scenario 56 | first_scenario_test() { 57 | ... test code for the first test case ... 58 | } 59 | 60 | shtk_unittest_add_test second_scenario 61 | second_scenario_test() { 62 | ... test code for the second test case ... 63 | } 64 | .Ed 65 | .Sh SEE ALSO 66 | .Xr shtk 3 , 67 | .Xr shtk_unittest 3 68 | .Sh HISTORY 69 | .Nm 70 | first appeared in 71 | .Nm shtk 72 | 1.6. 73 | -------------------------------------------------------------------------------- /bool_test.sh: -------------------------------------------------------------------------------- 1 | # Copyright 2013 Google Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google Inc. nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | shtk_import bool 30 | shtk_import unittest 31 | 32 | 33 | shtk_unittest_add_test check__true 34 | check__true_test() { 35 | for value in yes Yes YES true True TRUE 1; do 36 | expect_command -s exit:0 shtk_bool_check "${value}" 37 | done 38 | } 39 | 40 | 41 | shtk_unittest_add_test check__false 42 | check__false_test() { 43 | for value in no No NO false False FALSE 0; do 44 | expect_command -s exit:1 shtk_bool_check "${value}" 45 | done 46 | } 47 | 48 | 49 | shtk_unittest_add_test check__error__default_message 50 | check__error__default_message_test() { 51 | for value in 'yes ' ' no' 'foo'; do 52 | expect_command -s exit:1 \ 53 | -e match:"E: Invalid boolean value '${value}'" \ 54 | shtk_bool_check "${value}" 55 | done 56 | } 57 | 58 | 59 | shtk_unittest_add_test check__error__custom_message 60 | check__error__custom_message_test() { 61 | for value in 'yes ' ' no' 'foo'; do 62 | expect_command -s exit:1 \ 63 | -e match:"E: WRONG ${value}" \ 64 | shtk_bool_check "${value}" "WRONG ${value}" 65 | done 66 | } 67 | -------------------------------------------------------------------------------- /man/shtk_cli_info.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 5, 2014 29 | .Dt SHTK_CLI_INFO 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cli_info 33 | .Nd Prints an informational message 34 | .Sh LIBRARY 35 | shtk_import cli 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar message1 39 | .Op Ar .. messageN 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function prints the given informational message to stderr. 44 | The message can be provided as one or more arguments as depicted by 45 | .Ar message1 46 | to 47 | .Ar messageN ; 48 | all arguments are concatenated together into a single line. 49 | .Pp 50 | The printed message has the following form, where 51 | .Sq progname 52 | is determined by 53 | .Xr shtk_cli_progname 3 : 54 | .Bd -literal -offset indent 55 | progname: I: message1 .. messageN 56 | .Ed 57 | .Pp 58 | .Nm 59 | should be used to report script execution progress to the user instead of 60 | relying on simple 61 | .Xr echo 1 62 | calls. 63 | This is to ensure that all log messages are properly sent to stderr. 64 | .Sh SEE ALSO 65 | .Xr shtk 3 , 66 | .Xr shtk_cli 3 67 | .Sh HISTORY 68 | .Nm 69 | first appeared in 70 | .Nm shtk 71 | 1.0. 72 | -------------------------------------------------------------------------------- /man/shtk_hw_ncpus.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2017 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd February 6, 2017 29 | .Dt SHTK_HW_CPUS 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_hw_ncpus 33 | .Nd Queries the number of CPUs (threads) in the machine 34 | .Sh LIBRARY 35 | shtk_import hw 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Sh DESCRIPTION 39 | The 40 | .Nm 41 | function queries the number of CPU threads in the machine and prints the total 42 | number to stdout. 43 | .Pp 44 | If the query fails, or if the function does not know how to get the number from 45 | the current operating system, prints 1. 46 | .Sh RETURN VALUES 47 | .Nm 48 | returns 0. 49 | .Sh EXAMPLES 50 | .Bd -literal -offset indent 51 | make -j"$(shtk_hw_ncpus)" all 52 | .Ed 53 | .Sh ENVIRONMENT 54 | .Bl -tag -width XXXX 55 | .It Va SHTK_HW_NCPUS 56 | If set to a number greater than zero, overrides the return value of 57 | .Nm . 58 | Generally useful for testing purposes, but can also be useful to inject greater 59 | numbers of parallelism in applications that do not expose a mechanism to tune 60 | such number. 61 | .El 62 | .Sh SEE ALSO 63 | .Xr shtk 3 , 64 | .Xr shtk_hw 3 65 | .Sh HISTORY 66 | .Nm 67 | first appeared in 68 | .Nm shtk 69 | 1.7. 70 | -------------------------------------------------------------------------------- /shtk.m4: -------------------------------------------------------------------------------- 1 | dnl Copyright 2013 Google Inc. 2 | dnl All rights reserved. 3 | dnl 4 | dnl Redistribution and use in source and binary forms, with or without 5 | dnl modification, are permitted provided that the following conditions are 6 | dnl met: 7 | dnl 8 | dnl * Redistributions of source code must retain the above copyright 9 | dnl notice, this list of conditions and the following disclaimer. 10 | dnl * Redistributions in binary form must reproduce the above copyright 11 | dnl notice, this list of conditions and the following disclaimer in the 12 | dnl documentation and/or other materials provided with the distribution. 13 | dnl * Neither the name of Google Inc. nor the names of its contributors 14 | dnl may be used to endorse or promote products derived from this software 15 | dnl without specific prior written permission. 16 | dnl 17 | dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | dnl SHTK_CHECK([version-spec]) 30 | dnl 31 | dnl Checks if shtk is present and substitutes SHTK_TOOL with the full path to 32 | dnl the shtk(1) utility needed to "build" scripts that use shtk, and 33 | dnl SHTK_MODULESDIR with the location of the modules. 34 | dnl 35 | dnl \param version-spec If provided, indicates the version requirement for the 36 | dnl shtk pkgconfig package. This argument must be a version comparison 37 | dnl specification accepted by pkgconfig; e.g. '>= 1.3'. 38 | AC_DEFUN([SHTK_CHECK], [ 39 | spec="shtk[]m4_default_nblank([ $1], [])" 40 | AC_MSG_CHECKING([for ${spec}]) 41 | PKG_CHECK_EXISTS([${spec}], [found=yes], [found=no]) 42 | if test "${found}" = yes; then 43 | SHTK_MODULESDIR="$("${PKG_CONFIG}" --variable=shtk_modulesdir shtk)" 44 | AC_SUBST([SHTK_MODULESDIR], ["${SHTK_MODULESDIR}"]) 45 | SHTK_TOOL="$("${PKG_CONFIG}" --variable=shtk_tool shtk)" 46 | AC_SUBST([SHTK_TOOL], ["${SHTK_TOOL}"]) 47 | AC_MSG_RESULT([${SHTK_TOOL}]) 48 | else 49 | AC_MSG_RESULT([no]) 50 | AC_MSG_ERROR([Could not find shtk]) 51 | fi 52 | ]) 53 | -------------------------------------------------------------------------------- /man/shtk_unittest_skip.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 8, 2014 29 | .Dt SHTK_UNITTEST_SKIP 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_skip 33 | .Nd Skips the test currently being run 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Op Ar arg1 .. argN 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function marks the currently running test as skipped and aborts execution. 43 | The message given in the arguments 44 | .Ar arg1 45 | through 46 | .Ar argN 47 | is printed along the skip condition. 48 | .Pp 49 | Skipped tests do not count as failures: instead, they just represent a 50 | test that cannot be successfully be executed and is thus ignored. 51 | .Sh EXAMPLES 52 | Consider the following test case that requires a specific file to be 53 | present in the system: 54 | .Bd -literal -offset indent 55 | shtk_unittest_add_test motd_contents 56 | motd_contents_test() { 57 | [ -f /etc/motd ] || skip "/etc/motd not found; cannot validate" 58 | 59 | ... do something with /etc/motd here ... 60 | } 61 | .Ed 62 | .Sh SEE ALSO 63 | .Xr shtk 3 , 64 | .Xr shtk_unittest 3 65 | .Sh HISTORY 66 | .Nm 67 | first appeared in 68 | .Nm shtk 69 | 1.6. 70 | -------------------------------------------------------------------------------- /man/shtk_cli_debug.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2016 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd February 3, 2016 29 | .Dt SHTK_CLI_DEBUG 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cli_debug 33 | .Nd Prints a debug message 34 | .Sh LIBRARY 35 | shtk_import cli 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar message1 39 | .Op Ar .. messageN 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function prints the given debug message to stderr. 44 | The message can be provided as one or more arguments as depicted by 45 | .Ar message1 46 | to 47 | .Ar messageN ; 48 | all arguments are concatenated together into a single line. 49 | .Pp 50 | The printed message has the following form, where 51 | .Sq progname 52 | is determined by 53 | .Xr shtk_cli_progname 3 : 54 | .Bd -literal -offset indent 55 | progname: D: message1 .. messageN 56 | .Ed 57 | .Pp 58 | Debug-level messages are disabled by default and can be enabled with the 59 | .Xr shtk_cli_set_log_level 3 60 | function. 61 | Therefore, 62 | .Nm 63 | should be used to report information that is generally useful to debug a 64 | problem and not appropriate for regular usage. 65 | .Sh SEE ALSO 66 | .Xr shtk 3 , 67 | .Xr shtk_cli 3 68 | .Sh HISTORY 69 | .Nm 70 | first appeared in 71 | .Nm shtk 72 | 1.7. 73 | -------------------------------------------------------------------------------- /man/shtk_version.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 7, 2014 29 | .Dt SHTK_VERSION 3 30 | .Os 31 | .Sh NAME 32 | .Nm version 33 | .Nd Utilities to check the running version of shtk 34 | .Sh LIBRARY 35 | shtk_import 36 | .Nm 37 | .Sh DESCRIPTION 38 | The 39 | .Nm 40 | module provides functions to check and enforce constraints on the running 41 | version of shtk. 42 | .Pp 43 | Due to the dynamic nature of shell scripts, the functions provided by this 44 | module can be used to determine which modules and functions of 45 | .Nm shtk 46 | can be used in the script. 47 | This is the reason why every manual page in the 48 | .Xr shtk 3 49 | collection is tagged with a 50 | .Sx HISTORY 51 | section describing in which version each symbol first appeared. 52 | .Sh ENVIRONMENT 53 | The 54 | .Nm 55 | module offers the following variables for public consumption: 56 | .Bl -tag -width XXXX 57 | .It Va SHTK_VERSION 58 | The version number of the in-use 59 | .Xr shtk 3 60 | libraries. 61 | .El 62 | .Sh SEE ALSO 63 | .Xr shtk 3 , 64 | .Xr shtk_version_at_least 3 , 65 | .Xr shtk_version_at_most 3 , 66 | .Xr shtk_version_is 3 67 | .Sh HISTORY 68 | .Nm 69 | first appeared in 70 | .Nm shtk 71 | 1.5. 72 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl Copyright 2013 Google Inc. 2 | dnl All rights reserved. 3 | dnl 4 | dnl Redistribution and use in source and binary forms, with or without 5 | dnl modification, are permitted provided that the following conditions are 6 | dnl met: 7 | dnl 8 | dnl * Redistributions of source code must retain the above copyright 9 | dnl notice, this list of conditions and the following disclaimer. 10 | dnl * Redistributions in binary form must reproduce the above copyright 11 | dnl notice, this list of conditions and the following disclaimer in the 12 | dnl documentation and/or other materials provided with the distribution. 13 | dnl * Neither the name of Google Inc. nor the names of its contributors 14 | dnl may be used to endorse or promote products derived from this software 15 | dnl without specific prior written permission. 16 | dnl 17 | dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | AC_INIT([Shell Toolkit], [1.8], 30 | [https://github.com/jmmv/shtk/issues/], [shtk], []) 31 | AC_PREREQ([2.65]) 32 | 33 | 34 | AC_COPYRIGHT([Copyright 2013 Google Inc.]) 35 | AC_CONFIG_AUX_DIR([admin]) 36 | AC_CONFIG_FILES([Makefile]) 37 | AC_CONFIG_SRCDIR([shtk.sh]) 38 | 39 | 40 | AM_INIT_AUTOMAKE([1.9 foreign subdir-objects -Wall]) 41 | 42 | 43 | AC_PROG_LN_S 44 | 45 | 46 | AC_ARG_VAR([SHTK_SHELL], [Location of the POSIX shell interpreter to use]) 47 | if test "${SHTK_SHELL}" = ""; then 48 | AC_PATH_PROGS(SHTK_SHELL, [bash sh]) 49 | else 50 | case ${SHTK_SHELL} in 51 | /*) 52 | ;; 53 | *) 54 | AC_MSG_ERROR([SHTK_SHELL must hold an absolute path]) 55 | ;; 56 | esac 57 | fi 58 | if test "${SHTK_SHELL}" = ""; then 59 | AC_MSG_ERROR([No POSIX shell interpreter found; maybe set SHTK_SHELL?]) 60 | fi 61 | AC_MSG_NOTICE([Using shell interpreter ${SHTK_SHELL}]) 62 | 63 | 64 | AC_SUBST(aclocaldir, \${datadir}/aclocal) 65 | AC_SUBST(pkgconfigdir, \${libdir}/pkgconfig) 66 | AC_SUBST(pkgtestsdir, \${testsdir}/shtk) 67 | AC_SUBST(testsdir, \${exec_prefix}/tests) 68 | 69 | 70 | AC_OUTPUT 71 | -------------------------------------------------------------------------------- /man/shtk_unittest_fail.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 8, 2014 29 | .Dt SHTK_UNITTEST_FAIL 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_fail 33 | .Nd Fails the test case 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar arg1 .. argN 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function marks the currently running test case as failed and aborts 43 | execution. 44 | The message given in the arguments 45 | .Ar arg1 46 | through 47 | .Ar argN 48 | is printed along the failure. 49 | .Pp 50 | If 51 | .Nm 52 | is used within a test case of a test fixture, the 53 | .Nm teardown 54 | method of the fixture will be executed so that any necessary clean up 55 | operations can be performed. 56 | .Pp 57 | .Nm 58 | should be used to fail the test case when an erroneous condition is 59 | detected and such condition prevents the rest of the test case's 60 | code from running correctly. 61 | In general, this means that 62 | .Nm 63 | is appropriate to abort a test case when any setup operations not 64 | directly exercising the scenario under test cause an error. 65 | .Sh SEE ALSO 66 | .Xr shtk 3 , 67 | .Xr shtk_unittest 3 68 | .Sh HISTORY 69 | .Nm 70 | first appeared in 71 | .Nm shtk 72 | 1.6. 73 | -------------------------------------------------------------------------------- /git.subr: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Julio Merino 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | shtk_import bool 27 | shtk_import cli 28 | shtk_import process 29 | 30 | 31 | shtk_git_fetch() { 32 | local repo="${1}"; shift 33 | local branch="${1}"; shift 34 | local directory="${1}"; shift 35 | 36 | if [ -d "${directory}" ]; then 37 | shtk_git_update "${branch}" "${directory}" 38 | else 39 | shtk_git_clone "${repo}" "${branch}" "${directory}" 40 | fi 41 | } 42 | 43 | 44 | shtk_git_clone() { 45 | local repo="${1}"; shift 46 | local branch="${1}"; shift 47 | local directory="${1}"; shift 48 | 49 | [ ! -d "${directory}" ] || shtk_cli_error "Cannot clone into" \ 50 | "${directory}; directory already exists" 51 | shtk_process_run git clone -b "${branch}" "${repo}" \ 52 | "${directory}" || shtk_cli_error "git clone failed" 53 | } 54 | 55 | 56 | shtk_git_update() { 57 | local branch="${1}"; shift 58 | local directory="${1}"; shift 59 | 60 | [ -d "${directory}" ] || shtk_cli_error "Cannot update ${directory};" \ 61 | "directory does not exist" 62 | 63 | shtk_process_run -w "${directory}" git fetch origin "${branch}" \ 64 | || shtk_cli_error "git update failed" 65 | shtk_process_run -w "${directory}" git checkout "${branch}" \ 66 | || shtk_cli_error "git update failed" 67 | shtk_process_run -w "${directory}" git merge --ff-only "origin/${branch}" \ 68 | || shtk_cli_error "git update failed" 69 | } 70 | -------------------------------------------------------------------------------- /man/shtk_cvs_update.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 7, 2014 29 | .Dt SHTK_CVS_UPDATE 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cvs_update 33 | .Nd Updates an existing working copy of a CVS repository 34 | .Sh LIBRARY 35 | shtk_import cvs 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar cvsroot 39 | .Ar tag 40 | .Ar directory 41 | .Sh DESCRIPTION 42 | The 43 | .Nm 44 | function updates the existing working copy in 45 | .Ar directory 46 | from the CVS repository provided in 47 | .Ar cvsroot 48 | and 49 | .Ar tag . 50 | The CVS tag provided in 51 | .Ar tag 52 | can be empty, in which case the working copy is bought back up to 53 | .Sq HEAD . 54 | .Pp 55 | In general, you should resort to using the higher-level 56 | .Xr shtk_cvs_fetch 3 57 | wrapper as it properly handles the case of missing working copies. 58 | .Sh EXAMPLES 59 | .Bd -literal -offset indent 60 | shtk_cvs_update :ext:anoncvs@anoncvs.NetBSD.org:/cvsroot \\ 61 | netbsd-7 /usr/src 62 | .Ed 63 | .Sh ERRORS 64 | .Nm 65 | aborts execution with an error if the given 66 | .Ar directory 67 | does not yet exist or if the CVS update operation fails. 68 | .Sh SEE ALSO 69 | .Xr shtk 3 , 70 | .Xr shtk_cvs 3 71 | .Sh HISTORY 72 | .Nm 73 | first appeared in 74 | .Nm shtk 75 | 1.0. 76 | -------------------------------------------------------------------------------- /.github/workflows/build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Copyright 2014 Google Inc. 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # * Neither the name of Google Inc. nor the names of its contributors 15 | # may be used to endorse or promote products derived from this software 16 | # without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | set -e -x 31 | 32 | readonly SHELL_NAME="${1}"; shift 33 | readonly REQUIRED_TOOLS="${1}"; shift 34 | 35 | required_cvs=false 36 | for tool in ${REQUIRED_TOOLS}; do 37 | if ! which "${tool}" >/dev/null 2>&1; then 38 | echo "Expected tool ${tool} is not installed" 1>&2 39 | exit 1 40 | fi 41 | case "${tool}" in 42 | cvs) required_cvs=true ;; 43 | esac 44 | done 45 | if [ "${required_cvs}" = false ]; then 46 | if which "${tool}" >/dev/null 2>&1; then 47 | echo "Unexpected tool ${tool} is installed" 1>&2 48 | exit 1 49 | fi 50 | fi 51 | 52 | autoreconf -isv 53 | 54 | shell_path="$(which ${SHELL_NAME})" 55 | if [ ${?} -ne 0 ]; then 56 | echo "Failed to resolve path to shell ${SHELL_NAME}" 1>&2 57 | exit 1 58 | fi 59 | ./configure SHTK_SHELL="${shell_path}" 60 | 61 | ret=0 62 | make distcheck DISTCHECK_CONFIGURE_FLAGS="SHTK_SHELL='${shell_path}'" \ 63 | || ret="${?}" 64 | if [ ${ret} -ne 0 ]; then 65 | { 66 | echo "make distcheck failed!" 67 | log="$(find . -name test-suite.log)" 68 | if [ -f "${log}" ]; then 69 | echo "Contents of ${log}:" 70 | cat "${log}" 71 | fi 72 | } 1>&2 73 | exit ${ret} 74 | fi 75 | -------------------------------------------------------------------------------- /man/shtk_cli_log_level.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2016 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd February 3, 2016 29 | .Dt SHTK_CLI_LOG_LEVEL 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cli_log_level 33 | .Nd Checks if the given logging level is visible 34 | .Sh LIBRARY 35 | shtk_import cli 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar level 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function checks if the given logging level is currently being sent to stderr. 43 | The possible values for 44 | .Ar level 45 | are, in order of severity: 46 | .Sq error , 47 | .Sq warning , 48 | .Sq info 49 | and 50 | .Sq debug , 51 | and correspond to the various functions of the form 52 | .Sq shtk_cli_\*(Ltlevel\*(Gt . 53 | .Pp 54 | For example: after setting the level to 55 | .Sq warning , 56 | .Nm 57 | would return true for both error-level and warning-level messages, and would 58 | return false for both info-level and debug-level messages. 59 | .Pp 60 | It is important to note that error-level messages are always displayed. 61 | .Pp 62 | The current log level can be programmatically set with the 63 | .Xr shtk_cli_set_log_level 3 64 | function and the default level corresponds to 65 | .Sq info . 66 | .Sh SEE ALSO 67 | .Xr shtk 3 , 68 | .Xr shtk_cli_set_log_level 3 69 | .Sh HISTORY 70 | .Nm 71 | first appeared in 72 | .Nm shtk 73 | 1.7. 74 | -------------------------------------------------------------------------------- /man/shtk_cli_error.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 5, 2014 29 | .Dt SHTK_CLI_ERROR 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cli_error 33 | .Nd Prints a runtime error message and exits 34 | .Sh LIBRARY 35 | shtk_import cli 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar message1 39 | .Op Ar .. messageN 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function prints the given runtime error message to stderr and terminates 44 | execution of the script with a return value of 1. 45 | The message can be provided as one or more arguments as depicted by 46 | .Ar message1 47 | to 48 | .Ar messageN ; 49 | all arguments are concatenated together into a single line. 50 | .Pp 51 | The printed message has the following form, where 52 | .Sq progname 53 | is determined by 54 | .Xr shtk_cli_progname 3 : 55 | .Bd -literal -offset indent 56 | progname: E: message1 .. messageN 57 | .Ed 58 | .Pp 59 | .Nm 60 | should be used to bail out on erroneous conditions not directly caused by an 61 | invalid invocation of the script. 62 | For errors caused directly by the user, such as specifying an incorrect flag to 63 | the program, should be reported using 64 | .Xr shtk_cli_usage_error 3 . 65 | .Sh SEE ALSO 66 | .Xr shtk 3 , 67 | .Xr shtk_cli 3 68 | .Sh HISTORY 69 | .Nm 70 | first appeared in 71 | .Nm shtk 72 | 1.0. 73 | -------------------------------------------------------------------------------- /man/shtk_unittest_main.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 8, 2014 29 | .Dt SHTK_UNITTEST_MAIN 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_main 33 | .Nd Standard test program entry point 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Sh DESCRIPTION 39 | The 40 | .Nm 41 | function implements the standard entry point of a test program that uses the 42 | .Xr shtk_unittest 3 43 | library. 44 | The 45 | .Nm 46 | function runs all test cases registered within the test case and determines 47 | the correct exit condition for the test program. 48 | .Pp 49 | In order to use 50 | .Nm , 51 | test programs must either explicitly call the function from their 52 | .Nm main 53 | method as this: 54 | .Bd -literal -offset indent 55 | main() { shtk_unittest_main "${@}"; } 56 | .Ed 57 | .Pp 58 | Or the test program can be compiled with an override for the main method's 59 | name: 60 | .Bd -literal -offset indent 61 | $ shtk build -m shtk_unittest_main module_test.sh 62 | .Ed 63 | .Pp 64 | In general, prefer the latter mechanism. 65 | .Sh RETURN VALUES 66 | Returns 0 (true) if all executed test cases pass, or 1 (false) if any 67 | test fails. 68 | .Sh SEE ALSO 69 | .Xr shtk 3 , 70 | .Xr shtk_unittest 3 71 | .Sh HISTORY 72 | .Nm 73 | first appeared in 74 | .Nm shtk 75 | 1.6. 76 | -------------------------------------------------------------------------------- /man/shtk_cleanup_register.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 5, 2014 29 | .Dt SHTK_CLEANUP_REGISTER 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cleanup_register 33 | .Nd Installs cleanup handlers to be called on script termination 34 | .Sh LIBRARY 35 | shtk_import cleanup 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar handler1 39 | .Op Ar .. handlerN 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function installs one or more cleanup handlers, given in the 44 | .Ar handler1 45 | to 46 | .Ar handlerN 47 | arguments as function names. 48 | .Pp 49 | The registered handlers are executed in the order they are originally 50 | registered. 51 | Registration of handlers is idempotent. 52 | .Sh EXAMPLES 53 | The following example creates a temporary file and installs a cleanup 54 | handler to ensure that the file gets removed when the script terminates: 55 | .Bd -literal -offset indent 56 | local pattern="${TMPDIR:-/tmp}/my_program.XXXXXX" 57 | 58 | local temp_file="$(mktemp "${pattern}" 2>/dev/null)" 59 | [ -f "${temp_file}" ] || shtk_cli_error "Failed to create temporary file" 60 | 61 | eval "remove_temp_file() { rm -f '${temp_file}'; }" 62 | shtk_cleanup_register remove_temp_file 63 | .Ed 64 | .Sh SEE ALSO 65 | .Xr shtk 3 , 66 | .Xr shtk_cleanup 3 67 | .Sh HISTORY 68 | .Nm 69 | first appeared in 70 | .Nm shtk 71 | 1.4. 72 | -------------------------------------------------------------------------------- /fs.subr: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google Inc. nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | 30 | # Sed script to normalize a path. 31 | # 32 | # This is constructed in multiple steps for documentation purposes only; 33 | # we could just as well provide this as a one-liner within the 34 | # shtk_fs_normalize_path function... but the result is unreadable. 35 | # 36 | # 1st: Strip off any trailing . component and its associated slash. 37 | _Shtk_Fs_Normalize="s,/\.$,," 38 | # 2nd: Collapse multiple consecutive slashes. 39 | _Shtk_Fs_Normalize="${_Shtk_Fs_Normalize};s,/+,/,g" 40 | # 3rd: Collapse any intermediate . components. 41 | _Shtk_Fs_Normalize="${_Shtk_Fs_Normalize};s,/\./,/,g" 42 | # 4th: Remove trailing slashes. 43 | _Shtk_Fs_Normalize="${_Shtk_Fs_Normalize};/[^/]/s,/$,," 44 | # 5th: If the path is relative and does not already start with ., add it. 45 | _Shtk_Fs_Normalize="${_Shtk_Fs_Normalize};/^[./]/!s,^,./," 46 | 47 | 48 | shtk_fs_join_paths() { 49 | local result="${1}"; shift 50 | while [ ${#} -gt 0 ]; do 51 | result="${result}/${1}" 52 | shift 53 | done 54 | shtk_fs_normalize_path "${result}" 55 | } 56 | 57 | 58 | shtk_fs_normalize_path() { 59 | local unnormalized="${1}"; shift 60 | echo "${unnormalized}" | sed -E "${_Shtk_Fs_Normalize}" \ 61 | || shtk_abort "sed script failed in call to shtk_fs_normalize_path" \ 62 | "most likely a portability bug" 63 | } 64 | -------------------------------------------------------------------------------- /man/shtk_cli_set_log_level.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2016 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd February 3, 2016 29 | .Dt SHTK_CLI_SET_LOG_LEVEL 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cli_set_log_level 33 | .Nd Sets the level of the logging messages to display 34 | .Sh LIBRARY 35 | shtk_import cli 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar level 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function sets the maximum logging level of the messages that will be sent 43 | to stderr. 44 | The possible values for 45 | .Ar level 46 | are, in order of severity: 47 | .Sq error , 48 | .Sq warning , 49 | .Sq info 50 | and 51 | .Sq debug , 52 | and correspond to the various functions of the form 53 | .Sq shtk_cli_\*(Ltlevel\*(Gt . 54 | .Pp 55 | For example: setting the level to 56 | .Sq warning 57 | would display error-level and warning-level messages but would omit info-level 58 | and debug-level messages. 59 | This is an appropriate way of implementing a quiet/verbose mode in applications. 60 | .Pp 61 | It is important to note that error-level messages are always displayed because 62 | the minimum logging level that can be set is 63 | .Sq error . 64 | .Pp 65 | The current log level can be programmatically queried with the 66 | .Xr shtk_cli_log_level 3 67 | function and the default level corresponds to 68 | .Sq info . 69 | .Sh SEE ALSO 70 | .Xr shtk 3 , 71 | .Xr shtk_cli_log_level 3 72 | .Sh HISTORY 73 | .Nm 74 | first appeared in 75 | .Nm shtk 76 | 1.7. 77 | -------------------------------------------------------------------------------- /man/shtk_cvs_checkout.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 7, 2014 29 | .Dt SHTK_CVS_CHECKOUT 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cvs_checkout 33 | .Nd Checks out a new working copy out of a CVS repository 34 | .Sh LIBRARY 35 | shtk_import cvs 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar cvsroot 39 | .Ar module 40 | .Ar tag 41 | .Ar directory 42 | .Sh DESCRIPTION 43 | The 44 | .Nm 45 | function checks out a new working copy of the repository 46 | .Ar cvsroot 47 | into 48 | .Ar directory 49 | using the given 50 | .Ar module 51 | and 52 | .Ar tag . 53 | The 54 | .Ar directory 55 | must not exist. 56 | The CVS tag provided in 57 | .Ar tag 58 | can be empty, in which case the working copy is checked out from 59 | .Sq HEAD . 60 | .Pp 61 | In general, you should resort to using the higher-level 62 | .Xr shtk_cvs_fetch 3 63 | wrapper as it properly handles the case of already existing working 64 | copies (which could be caused by a previously aborted checkout, for 65 | example). 66 | .Sh EXAMPLES 67 | .Bd -literal -offset indent 68 | shtk_cvs_checkout :ext:anoncvs@anoncvs.NetBSD.org:/cvsroot \\ 69 | src netbsd-7 /usr/src 70 | .Ed 71 | .Sh ERRORS 72 | .Nm 73 | aborts execution with an error if the given 74 | .Ar directory 75 | already exists or if the CVS checkout operation fails. 76 | .Sh SEE ALSO 77 | .Xr shtk 3 , 78 | .Xr shtk_cvs 3 79 | .Sh HISTORY 80 | .Nm 81 | first appeared in 82 | .Nm shtk 83 | 1.0. 84 | -------------------------------------------------------------------------------- /man/shtk_abort.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2016 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd September 14, 2016 29 | .Dt SHTK_ABORT 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_abort 33 | .Nd Aborts the program with an optional error message 34 | .Sh SYNOPSIS 35 | .Nm 36 | .Op Ar message1 .. messageN 37 | .Sh DESCRIPTION 38 | The 39 | .Nm 40 | function prints the given error message to stderr and terminates 41 | execution of the script, including all subshells leading up to the call to 42 | .Nm . 43 | .Pp 44 | The exit code of the script is non-zero but unspecified. 45 | .Pp 46 | The message, if provided, can be broken up as one or more arguments as 47 | depicted by 48 | .Ar message1 49 | to 50 | .Ar messageN ; 51 | all arguments are concatenated together into a single line. 52 | .Pp 53 | It is important to note that 54 | .Nm 55 | should be used exclusively to abruptly abort the script due to an internal 56 | error or inconsistency. 57 | Think of this function as a mechanism to implement assertions: 58 | .Bd -literal -offset indent 59 | [ -n "${should_be_set}" ] || shtk_abort "Internal variable not set!" 60 | .Ed 61 | .Pp 62 | This is why 63 | .Nm 64 | is 65 | .Em not 66 | in the 67 | .Xr shtk_cli 3 68 | module, because it is not meant to provide a mechanism for clean program 69 | terminations and because it is provided for self-diagnostics purposes. 70 | .Sh SEE ALSO 71 | .Xr shtk 3 , 72 | .Xr shtk_cli 3 73 | .Sh HISTORY 74 | .Nm 75 | first appeared in 76 | .Nm shtk 77 | 1.7. 78 | -------------------------------------------------------------------------------- /man/shtk_cvs_fetch.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 7, 2014 29 | .Dt SHTK_CVS_FETCH 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cvs_fetch 33 | .Nd Checks out or updates a CVS working copy 34 | .Sh LIBRARY 35 | shtk_import cvs 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar cvsroot 39 | .Ar module 40 | .Ar tag 41 | .Ar directory 42 | .Sh DESCRIPTION 43 | The 44 | .Nm 45 | function is a simple wrapper over the lower-level 46 | .Xr shtk_cvs_checkout 3 47 | and 48 | .Xr shtk_cvs_update 3 49 | functions, using one or the other depending on the status of the local 50 | working copy. 51 | .Pp 52 | More specifically: if 53 | .Ar directory 54 | does not yet exist or it is empty, the 55 | .Nm 56 | function checks out a new working copy of the repository 57 | .Ar cvsroot 58 | into it using the given 59 | .Ar module 60 | and 61 | .Ar tag . 62 | If 63 | .Ar directory 64 | does exist and contains a 65 | .Pa CVS 66 | control directory, then the 67 | .Nm 68 | function performs a working copy update of the repository using the given 69 | .Ar tag . 70 | .Pp 71 | The CVS tag provided in 72 | .Ar tag 73 | can be empty, in which case the working copy is checked out from 74 | .Sq HEAD . 75 | .Sh EXAMPLES 76 | .Bd -literal -offset indent 77 | shtk_cvs_fetch :ext:anoncvs@anoncvs.NetBSD.org:/cvsroot \\ 78 | src netbsd-7 /usr/src 79 | .Ed 80 | .Sh SEE ALSO 81 | .Xr shtk 3 , 82 | .Xr shtk_cvs 3 83 | .Sh HISTORY 84 | .Nm 85 | first appeared in 86 | .Nm shtk 87 | 1.0. 88 | -------------------------------------------------------------------------------- /cleanup.subr: -------------------------------------------------------------------------------- 1 | # Copyright 2013 Google Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google Inc. nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | shtk_import bool 30 | shtk_import list 31 | 32 | 33 | # List of registered cleanup handlers (function names). 34 | _Shtk_Cleanup_Handlers= 35 | 36 | 37 | # List of exit traps that execute the cleanup handlers. 38 | _Shtk_Cleanup_Traps="EXIT HUP INT TERM" 39 | 40 | 41 | # Whether the exit traps have been installed or not. 42 | _Shtk_Cleanup_Installed=false 43 | 44 | 45 | # Executes all installed cleanup handlers. 46 | _shtk_cleanup_run_handlers() { 47 | local signo="${1}"; shift 48 | local exitcode="${1}"; shift 49 | 50 | for handler in ${_Shtk_Cleanup_Handlers}; do 51 | eval "${handler}" || true 52 | done 53 | 54 | trap - ${_Shtk_Cleanup_Traps} # Prevent double execution. 55 | if [ "${signo}" = EXIT ]; then 56 | exit "${exitcode}" 57 | else 58 | kill "-${signo}" ${$} 59 | fi 60 | } 61 | 62 | 63 | # Sets up exit traips to run the cleanup handlers. 64 | _shtk_cleanup_install_traps() { 65 | if shtk_bool_check "${_Shtk_Cleanup_Installed}"; then 66 | return 0 67 | fi 68 | for code in ${_Shtk_Cleanup_Traps}; do 69 | trap "_shtk_cleanup_run_handlers '${code}' \$?" "${code}" 70 | done 71 | _Shtk_Cleanup_Installed=true 72 | } 73 | 74 | 75 | shtk_cleanup_register() { 76 | for funcname in "${@}"; do 77 | shtk_list_contains "${funcname}" ${_Shtk_Cleanup_Handlers} \ 78 | || _Shtk_Cleanup_Handlers="${_Shtk_Cleanup_Handlers} ${funcname}" 79 | done 80 | _shtk_cleanup_install_traps 81 | } 82 | -------------------------------------------------------------------------------- /man/shtk_cli_usage_error.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd July 11, 2017 29 | .Dt SHTK_CLI_USAGE_ERROR 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cli_usage_error 33 | .Nd Prints a usage error and exits 34 | .Sh LIBRARY 35 | shtk_import cli 36 | .Sh SYNOPSIS 37 | .Nm shtk_cli_usage_error 38 | .Ar message1 39 | .Op Ar .. messageN 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function prints the given usage error message to stderr and terminates 44 | execution of the script with a return value of 1. 45 | The message can be provided as one or more arguments as depicted by 46 | .Ar message1 47 | to 48 | .Ar messageN ; 49 | all arguments are concatenated together into a single line. 50 | .Pp 51 | The printed message has the following form, where 52 | .Sq progname 53 | is determined by 54 | .Xr shtk_cli_progname 3 : 55 | .Bd -literal -offset indent 56 | progname: E: message1 .. messageN 57 | Type 'man progname' for help. 58 | .Ed 59 | .Pp 60 | .Nm 61 | should be used to inform the user of problems directly caused by his invocation 62 | of the script (e.g. the use of an invalid flag). 63 | .Pp 64 | By default, the printed error message refers to a manual page for the script. 65 | You should have one, but if you don't, you can use the 66 | .Xr shtk_cli_set_help_command 3 67 | function early on in your script to customize the command shown to the user. 68 | .Sh SEE ALSO 69 | .Xr shtk 3 , 70 | .Xr shtk_cli 3 , 71 | .Xr shtk_cli_set_help_command 3 72 | .Sh HISTORY 73 | .Nm 74 | first appeared in 75 | .Nm shtk 76 | 1.0. 77 | -------------------------------------------------------------------------------- /man/shtk_process_run.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd January 6, 2025 29 | .Dt SHTK_PROCESS_RUN 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_process_run 33 | .Nd Executes a command in a controlled environment 34 | .Sh LIBRARY 35 | shtk_import run 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Op Fl t Ar seconds 39 | .Op Fl w Ar work_dir 40 | .Ar command 41 | .Op Ar arg1 .. argN 42 | .Sh DESCRIPTION 43 | The 44 | .Nm 45 | function executes the command provided in the list of arguments starting at 46 | .Ar command 47 | and logs, using the logging functions offered by 48 | .Xr shtk_cli 3 , 49 | the invocation of the command and its termination status. 50 | .Pp 51 | The command given to 52 | .Nm 53 | is executed in the current directory, unless the 54 | .Fl w Ar work_dir 55 | flag is used to specify a different work directory. 56 | .Pp 57 | Optionally, 58 | .Nm 59 | can enforce a maximum run time for the executed command. 60 | If the 61 | .Fl t 62 | is provided, then the executed command will be forcibly terminated with a 63 | .Sq KILL 64 | signal if its run time exceeds the given 65 | .Ar seconds . 66 | .Sh RETURN VALUES 67 | .Nm 68 | returns the exit code of the executed command, or 127 if a timeout was provided 69 | and the command timed out. 70 | .Sh SEE ALSO 71 | .Xr shtk 3 , 72 | .Xr shtk_process 3 73 | .Sh HISTORY 74 | .Nm 75 | first appeared in 76 | .Nm shtk 77 | 1.0. 78 | .Pp 79 | The 80 | .Fl t 81 | flag appeared in 82 | .Nm shtk 83 | 1.5. 84 | .Pp 85 | The 86 | .Fl w 87 | flag appeared in 88 | .Nm shtk 89 | 1.8. 90 | -------------------------------------------------------------------------------- /man/shtk_fs_normalize_path.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2016 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd September 18, 2016 29 | .Dt SHTK_FS_NORMALIZE_PATH 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_fs_normalize_path 33 | .Nd Returns a normalized form of a path 34 | .Sh LIBRARY 35 | shtk_import fs 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar path 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function takes the given 43 | .Ar path 44 | and prints its normalized form to stdout. 45 | .Pp 46 | This process involves the following: 47 | .Bl -bullet 48 | .It 49 | Collapsing multiple consecutive forward slashes into one. 50 | .It 51 | Adding a 52 | .Pa \&. 53 | component at the beginning of the path if it is relative. 54 | .It 55 | Removing any 56 | .Pa \&. 57 | components, except for the first one. 58 | .It 59 | Removing any trailing slashes. 60 | .El 61 | .Pp 62 | Note that the normalization happens 63 | .Em without 64 | performing any file system operations. 65 | Therefore, it is perfectly possible for two normalized paths that look different 66 | to point to the same file system entry. 67 | In particular, this is because normalization does not take into account links 68 | nor 69 | .Pa .. 70 | components. 71 | .Sh RETURN VALUES 72 | .Nm 73 | returns 0. 74 | .Sh EXAMPLES 75 | .Bd -literal -offset indent 76 | shtk_fs_normalize_path /foo/bar # Prints /foo/bar 77 | shtk_fs_normalize_path foo/bar # Prints ./foo/bar 78 | shtk_fs_normalize_path foo///bar/./baz// # Prints ./foo/bar/baz 79 | .Ed 80 | .Sh SEE ALSO 81 | .Xr shtk 3 , 82 | .Xr shtk_fs 3 83 | .Sh HISTORY 84 | .Nm 85 | first appeared in 86 | .Nm shtk 87 | 1.7. 88 | -------------------------------------------------------------------------------- /man/shtk_bool_check.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 5, 2014 29 | .Dt SHTK_BOOL_CHECK 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_bool_check 33 | .Nd Converts a string to a boolean value 34 | .Sh LIBRARY 35 | shtk_import bool 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar value 39 | .Op Ar error_message 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function takes the string 44 | .Ar value 45 | and returns the corresponding boolean value according to shell conventions. 46 | .Sh RETURN VALUES 47 | .Nm 48 | returns 0 for any 49 | .Ar value 50 | representing truth. 51 | These include the strings 52 | .Sq yes 53 | and 54 | .Sq true , 55 | including any variations in their capitalization, and the integer number 56 | .Sq 1 . 57 | .Pp 58 | .Nm 59 | returns 1 for any 60 | .Ar value 61 | representing falsehood. 62 | These include the strings 63 | .Sq no 64 | and 65 | .Sq false , 66 | including any variations in their capitalization, and the integer number 67 | .Sq 0 . 68 | .Sh EXAMPLES 69 | .Bd -literal -offset indent 70 | local verbose=no 71 | # Parse flags to see if verbose mode is enabled and set verbose=yes. 72 | 73 | if shtk_bool_check "${verbose}"; then 74 | # Print messages. 75 | fi 76 | .Ed 77 | .Sh ERRORS 78 | .Nm 79 | prints the error given in 80 | .Ar error_message 81 | and exits the shell with non-zero if the 82 | .Ar value 83 | does not represent a valid boolean value. 84 | If 85 | .Ar error_message 86 | is not provided, a default message is printed. 87 | .Sh SEE ALSO 88 | .Xr shtk 3 , 89 | .Xr shtk_bool 3 90 | .Sh HISTORY 91 | .Nm 92 | first appeared in 93 | .Nm shtk 94 | 1.4. 95 | -------------------------------------------------------------------------------- /man/shtk_cli_set_help_command.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2017 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd July 11, 2017 29 | .Dt SHTK_CLI_SET_HELP_COMMAND 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_cli_set_help_command 33 | .Nd Sets the interactive command to get additional help 34 | .Sh LIBRARY 35 | shtk_import cli 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar message1 39 | .Op Ar .. messageN 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function sets the command that a user can type to get additional help when 44 | the typed command contains a usage error. 45 | The value set by this function is used by 46 | .Xr shtk_cli_usage_error 3 . 47 | The message can be provided as one or more arguments as depicted by 48 | .Ar message1 49 | to 50 | .Ar messageN ; 51 | all arguments are concatenated together into a single line. 52 | .Pp 53 | .Sh EXAMPLES 54 | The following could be used to point users to a GNU Info document: 55 | .Bd -literal -offset indent 56 | main() { 57 | shtk_cli_set_help_command "info $(shtk_cli_progname)" 58 | ... 59 | if [ ${#} -gt 0 ]; then 60 | shtk_usage_error "No arguments allowed" 61 | fi 62 | } 63 | .Ed 64 | .Pp 65 | And the following could be used to tell the user to access built-in 66 | documentation: 67 | .Bd -literal -offset indent 68 | main() { 69 | shtk_cli_set_help_command "$(shtk_cli_progname) --help" 70 | ... 71 | if [ ${#} -gt 0 ]; then 72 | shtk_usage_error "No arguments allowed" 73 | fi 74 | } 75 | .Ed 76 | .Sh SEE ALSO 77 | .Xr shtk 3 , 78 | .Xr shtk_cli 3 , 79 | .Xr shtk_cli_usage_error 3 80 | .Sh HISTORY 81 | .Nm 82 | first appeared in 83 | .Nm shtk 84 | 1.8. 85 | -------------------------------------------------------------------------------- /man/shtk_config_load.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 6, 2014 29 | .Dt SHTK_CONFIG_LOAD 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_config_load 33 | .Nd Loads a configuration file 34 | .Sh LIBRARY 35 | shtk_import config 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar config_file 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function parses and loads the configuration file given by 43 | .Ar config_file . 44 | .Pp 45 | Only the configuration variables previously registered as valid with a call to 46 | .Xr shtk_config_init 3 47 | will be recognized as valid variables during load. 48 | Any variables defined by the configuration file but not registered in the 49 | .Nm 50 | module will be ignored during load. 51 | .Sh EXAMPLES 52 | Consider the following configuration file: 53 | .Bd -literal -offset indent 54 | prefix=/usr 55 | OBJDIR="${prefix}/obj" 56 | SRCDIR="${prefix}/src" 57 | .Ed 58 | .Pp 59 | The following piece of code illustrates how to load and display the settings 60 | of the file above: 61 | .Bd -literal -offset indent 62 | shtk_config_init OBJDIR SRCDIR 63 | shtk_config_load ".../path/to/the/file/above.conf" 64 | 65 | echo "prefix was defined but is not available:" \\ 66 | "$(shtk_config_get_default prefix default-value)" 67 | echo "OBJDIR is $(shtk_config_get OBJDIR)" 68 | echo "SRCDIR is $(shtk_config_get SRCDIR)" 69 | .Ed 70 | .Sh ERRORS 71 | Errors during the processing of 72 | .Ar config_file 73 | result in the termination of the caller script. 74 | .Sh SEE ALSO 75 | .Xr shtk 3 , 76 | .Xr shtk_config 3 77 | .Sh HISTORY 78 | .Nm 79 | first appeared in 80 | .Nm shtk 81 | 1.0. 82 | -------------------------------------------------------------------------------- /man/shtk_unittest_add_fixture.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 8, 2014 29 | .Dt SHTK_UNITTEST_ADD_FIXTURE 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_unittest_add_fixture 33 | .Nd Defines a test fixture 34 | .Sh LIBRARY 35 | shtk_import unittest 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar name 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function registers the fixture given by 43 | .Ar name . 44 | A function named 45 | .Sq \*(Ltname\*(Gt_fixture 46 | must be defined 47 | .Em after 48 | the call to 49 | .Nm 50 | has been made. 51 | .Pp 52 | Fixture functions must not directly contain any code. 53 | All they can do is define other functions, such as 54 | .Nm setup 55 | and 56 | .Nm teardown , 57 | and execute calls to 58 | .Xr shtk_unittest_add_test 3 . 59 | .Sh EXAMPLES 60 | The following piece of code illustrates the components of a test fixture: 61 | .Bd -literal -offset indent 62 | shtk_unittest_add_fixture my_collection 63 | my_collection_fixture() { 64 | setup() { 65 | ... optional function providing per-test setup code ... 66 | } 67 | 68 | teardown() { 69 | ... optional function providing per-test teardown code ... 70 | } 71 | 72 | shtk_unittest_add_test first_scenario 73 | first_scenario_test() { 74 | ... test code for the first test case ... 75 | } 76 | 77 | shtk_unittest_add_test second_scenario 78 | second_scenario_test() { 79 | ... test code for the second test case ... 80 | } 81 | } 82 | .Ed 83 | .Sh SEE ALSO 84 | .Xr shtk 3 , 85 | .Xr shtk_unittest 3 86 | .Sh HISTORY 87 | .Nm 88 | first appeared in 89 | .Nm shtk 90 | 1.6. 91 | -------------------------------------------------------------------------------- /unittest/operators.subr: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google Inc. nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | shtk_import cli 30 | #shtk_import unittest # unittest imports us, so we can assume it is present. 31 | 32 | 33 | # Compares two values for equality. 34 | # 35 | # wrapper: Name of the calling function for error reporting purposes. 36 | # fail_function: Function to use to report a failure. 37 | # expected_value: Expected value. 38 | # actual_value: Actual value. 39 | # 40 | # If fail_function is not terminal, returns true if the expected value 41 | # is equal to the actual value; false otherwise. 42 | _shtk_unittest_check_equal() { 43 | local wrapper="${1}"; shift 44 | local fail_function="${1}"; shift 45 | local expected_value="${1}"; shift 46 | local actual_value="${1}"; shift 47 | 48 | [ "${expected_value}" = "${actual_value}" ] || \ 49 | "${fail_function}" "Expected value ${expected_value} but got" \ 50 | "${actual_value}" 51 | } 52 | _shtk_unittest_register_check equal 53 | 54 | 55 | # Compares two values for inequality. 56 | # 57 | # wrapper: Name of the calling function for error reporting purposes. 58 | # fail_function: Function to use to report a failure. 59 | # unexpected_value: Unexpected value. 60 | # actual_value: Actual value. 61 | # 62 | # If fail_function is not terminal, returns true if the unexpected value 63 | # is different than the actual value; false otherwise. 64 | _shtk_unittest_check_not_equal() { 65 | local wrapper="${1}"; shift 66 | local fail_function="${1}"; shift 67 | local expected_value="${1}"; shift 68 | local actual_value="${1}"; shift 69 | 70 | [ "${expected_value}" != "${actual_value}" ] || \ 71 | "${fail_function}" "Expected value different than ${expected_value}" 72 | } 73 | _shtk_unittest_register_check not_equal 74 | -------------------------------------------------------------------------------- /version.subr.in: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google Inc. nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | 30 | # The version of the installed shtk modules. 31 | SHTK_VERSION="__SHTK_VERSION__" 32 | 33 | 34 | shtk_version_at_least() { 35 | local version="${1}"; shift 36 | 37 | local major_installed="$(echo "${SHTK_VERSION}" | cut -d . -f 1)" 38 | local major_requested="$(echo "${version}" | cut -d . -f 1)" 39 | if [ "${major_installed}" -lt "${major_requested}" ]; then 40 | return 1 41 | elif [ "${major_installed}" -gt "${major_requested}" ]; then 42 | return 0 43 | else 44 | local minor_installed="$(echo "${SHTK_VERSION}" | cut -d . -f 2)" 45 | local minor_requested="$(echo "${version}" | cut -d . -f 2)" 46 | if [ "${minor_installed}" -ge "${minor_requested}" ]; then 47 | return 0 48 | else 49 | return 1 50 | fi 51 | fi 52 | } 53 | 54 | 55 | shtk_version_at_most() { 56 | local version="${1}"; shift 57 | 58 | local major_installed="$(echo "${SHTK_VERSION}" | cut -d . -f 1)" 59 | local major_requested="$(echo "${version}" | cut -d . -f 1)" 60 | if [ "${major_installed}" -lt "${major_requested}" ]; then 61 | return 0 62 | elif [ "${major_installed}" -gt "${major_requested}" ]; then 63 | return 1 64 | else 65 | local minor_installed="$(echo "${SHTK_VERSION}" | cut -d . -f 2)" 66 | local minor_requested="$(echo "${version}" | cut -d . -f 2)" 67 | if [ "${minor_installed}" -le "${minor_requested}" ]; then 68 | return 0 69 | else 70 | return 1 71 | fi 72 | fi 73 | } 74 | 75 | 76 | shtk_version_is() { 77 | local version="${1}"; shift 78 | 79 | [ "${version}" = "${SHTK_VERSION}" ] || return 1 80 | return 0 81 | } 82 | -------------------------------------------------------------------------------- /man/shtk_config_override.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 6, 2014 29 | .Dt SHTK_CONFIG_OVERRIDE 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_config_override 33 | .Nd Records an override to be applied to the configuration 34 | .Sh LIBRARY 35 | shtk_import config 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar override 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | function records the override given in 43 | .Ar override , 44 | which must have the form 45 | .Sq variable=value . 46 | .Pp 47 | Overrides are values given to configuration variables that can be set 48 | .Em before 49 | the configuration file is loaded with 50 | .Xr shtk_config_load 3 . 51 | This feature is useful to support parsing all command line flags before 52 | attempting to load the configuration file, as the script should first 53 | validate all user input before performing any action. 54 | .Sh EXAMPLES 55 | This code snippet illustrates a program with a configuration file that 56 | supports a 57 | .Va VERBOSE 58 | variable and that, for convenience reasons, can be overriden via the 59 | command line using the 60 | .Fl v 61 | flag: 62 | .Bd -literal -offset indent 63 | shtk_config_init VERBOSE 64 | 65 | local OPTIND 66 | while getopts ':v' arg "${@}"; do 67 | case "${arg}" in 68 | v) # Enable verbose mode. 69 | shtk_config_override VERBOSE=yes 70 | ;; 71 | \\?) 72 | shtk_cli_usage_error "Unknown option -${OPTARG}" 73 | ;; 74 | esac 75 | done 76 | shift $((${OPTIND} - 1)) 77 | 78 | shtk_config_set VERBOSE no # Set the default value. 79 | shtk_config_load "/etc/my_program.conf" 80 | .Ed 81 | .Sh SEE ALSO 82 | .Xr shtk 3 , 83 | .Xr shtk_config 3 84 | .Sh HISTORY 85 | .Nm 86 | first appeared in 87 | .Nm shtk 88 | 1.0. 89 | -------------------------------------------------------------------------------- /man/shtk_config_run_hook.3: -------------------------------------------------------------------------------- 1 | .\" Copyright 2014 Google Inc. 2 | .\" All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions are 6 | .\" met: 7 | .\" 8 | .\" * Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" * Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" * Neither the name of Google Inc. nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | .Dd November 6, 2014 29 | .Dt SHTK_CONFIG_RUN_HOOK 3 30 | .Os 31 | .Sh NAME 32 | .Nm shtk_config_run_hook 33 | .Nd Executes a hook defined in a configuration file 34 | .Sh LIBRARY 35 | shtk_import config 36 | .Sh SYNOPSIS 37 | .Nm 38 | .Ar hook 39 | .Op Ar arg1 .. argN 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | function executes the function 44 | .Ar hook , 45 | defined by the configuration file, in the same context as the file. 46 | Any arguments 47 | .Ar arg1 48 | to 49 | .Ar argN 50 | are passed literally to the hook. 51 | Hooks should not be executed directly because otherwise they would need to 52 | use the 53 | .Xr shtk_config_get 3 54 | familiy of functions to read the variables defined in the file, which could be 55 | quite strange. 56 | .Pp 57 | Keep in mind that the hook will only be able to access the configuration 58 | variables previously registered with 59 | .Xr shtk_config_init 3 . 60 | Any other variables will be hidden and not available to the hook. 61 | .Sh EXAMPLES 62 | Consider the following configuration file: 63 | .Bd -literal -offset indent 64 | SRCDIR=/usr/src 65 | 66 | show_srcdir_hook() { 67 | # Note that we can access SRCDIR directly, as would be normal in a 68 | # configuration file. No need to use shtk_config_get. 69 | echo "SRCDIR is ${SRCDIR}" 70 | } 71 | .Ed 72 | .Pp 73 | Then, we could process the file and execute the defined hook like this: 74 | .Bd -literal -offset indent 75 | shtk_config_init SRCDIR 76 | shtk_config_load ".../path/to/the/file/above.conf" 77 | 78 | # This will print nothing because SRCDIR is not available here. 79 | echo "SRCDIR is ${SRCDIR}" 80 | 81 | # But this will display the right SRCDIR value. 82 | shtk_config_run_hook show_srcdir_hook 83 | .Ed 84 | .Sh ERRORS 85 | Errors during the execution of the hook result in the termination of the 86 | script. 87 | .Sh SEE ALSO 88 | .Xr shtk 3 , 89 | .Xr shtk_config 3 90 | .Sh HISTORY 91 | .Nm 92 | first appeared in 93 | .Nm shtk 94 | 1.1. 95 | --------------------------------------------------------------------------------