Some libraries written in shell script, used in a few private and public projets at Evolix
Find a file
2025-01-27 07:50:06 +01:00
lib Add a GNU GPLv3 license 2025-01-27 07:50:06 +01:00
test os-release: add new functions for os-release variables 2024-12-18 14:31:32 +01:00
.gitignore Vagrantfile for Debian with tests and libraries at the right place 2024-12-14 12:59:08 +01:00
CHANGELOG.md Add a GNU GPLv3 license 2025-01-27 07:50:06 +01:00
example.sh CHANGELOG, README + example.sh 2024-12-17 20:56:39 +01:00
LICENSE Add a GNU GPLv3 license 2025-01-27 07:50:06 +01:00
README.md typo 2024-12-17 20:57:12 +01:00
Vagrantfile mention OpenBSD in Vagrantfile 2024-12-19 09:45:31 +01:00

Evolibs Shell

A cocktail of libraries to use in your Shell scripts.

Libraries

calendar

Functions to know if now is a holiday, a working day, a working hour…

os-release

Functions to know if the OS is Debian and which version it is.

Usage

Those libraries should be installed in /usr/[local/]lib/evolibs-shell, but you can put them wherever you want.

They can be sourced all at once or one by one.

There is an example.sh script in the repository.

Tests

The test suite is based on Bats.

On Debian, you can apt install bats.

You can run the tests locally :

$ EVOLIBS_SHELL_LIB=./lib bats test/*.bats
/path/to/test/calendar.bats
 ✓ is_holiday returns nothing
 ✓ is_holiday returns 0 for January 1st
 ✓ is_holiday returns 1 for January 2nd
 ✓ is_weekend returns nothing
 ✓ is_weekend returns 1 when it's monday/tuesday/wednesday/thursday/friday
 ✓ is_weekend returns 0 when it's saturday/sunday
 ✓ is_workday returns nothing
 ✓ is_workday returns 1 for a holiday or weekend
 ✓ is_workday returns 0 a regular weekday
 ✓ is_worktime returns nothing
 ✓ is_worktime returns 0 for a regular weekday during working hours
 ✓ is_worktime returns 1 for a regular weekday outside working hours
/path/to/test/os-release.bats
 ✓ parse reads default file
 ✓ parse reads custom file
 ✓ is_debian without values
 ✓ is_debian with version
 ✓ is_debian with version and operator
 ✓ is_debian with bad operator

18 tests, 0 failures