Skip to content

logisparte/shell-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

75196a1 · Jun 26, 2024

History

13 Commits
Jun 26, 2024
Jun 26, 2024
Jun 26, 2024
Jun 15, 2024
Jun 26, 2024
Jun 26, 2024
Jun 26, 2024
Jun 26, 2024
Jun 21, 2024
Jun 26, 2024
Jun 26, 2024
Jun 26, 2024
Jun 15, 2024
Jun 15, 2024
May 17, 2024

Repository files navigation

shell-utils

Collection of POSIX-compatible shell utility functions to simplify script writing

License

This repository is distributed under the terms of the Apache 2.0 license

Users

Usage

  • Copy/paste any file in /src into your project's /scripts/utils directory. Make sure to preserve its relative path and to also copy over its dependencies (sourced utility files at the top) if applicable.
  • Source the file from any shell script in your project, example: . ./scripts/utils/report.sh
  • Use the sourced function locally

Documentation

Each utility has a documentation page here.

Contributors

First, clone the repository and configure the git hooks:

git clone [email protected]:logisparte/shell-utils.git
cd shell-utils
git config --local core.hooksPath "$PWD/hooks"

docker-env

This repository uses docker-env to encapsulate its development environment inside a Docker container.

To build the docker dev image:

./docker/env.sh init

To start a development container:

./docker/env.sh up

To execute a command inside the development container:

./docker/env.sh exec COMMAND

To open a shell inside the development container

./docker/env.sh shell

To stop the development container:

./docker/env.sh down

For more information about docker-env, use ./docker/env.sh --help and read the documentation

Scripts

Format

shfmt is used to format shell files. Prettier is used to format markdown and yaml files. To format dirty files:

./scripts/format.sh

To format all files:

./scripts/format.sh all

Lint

ShellCheck is used to analyze shell code. MarkdownLint is used to analyze markdown code. To analyze dirty files:

./scripts/lint.sh

To analyze all files:

./scripts/lint.sh all

Test

ShellSpec is used to test the source code. To run all tests:

./scripts/test.sh

To run a specific test suite:

./scripts/test.sh SUITE

Coverage

Kcov is used to measure test coverage during tests. To view the coverage report after a test run:

./scripts/coverage.sh

NOTE: Multiline strings may report as non-covered due this issue