https://github.com/acook/modern.sh
Modern helpers for shell scripting
https://github.com/acook/modern.sh
Last synced: 10 months ago
JSON representation
Modern helpers for shell scripting
- Host: GitHub
- URL: https://github.com/acook/modern.sh
- Owner: acook
- Created: 2021-11-21T11:55:22.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-23T13:06:23.000Z (about 2 years ago)
- Last Synced: 2025-07-05T00:11:34.835Z (12 months ago)
- Language: Shell
- Size: 133 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# modern.sh
Modern helpers for shell scripting.
----
I end up using a lot of shell scripting for portability and efficiency reasons.
As designed it is great for glue logic. But shell scripting has a lot of gaps.
`modern.sh` fills some of these gaps by providing such capabilities as:
- Including scripts as libraries - and ensuring they're only loaded once
- Compatibility stubs and wrappers to ease development between Linux and BSD-like environments
- Best-practice application of shell commands and features (like `safe_cd`)
- Copious user feedback and visual indicators that are easy to read to aid debugability
Usage
=====
There is almost no boilerplate for your entry script to reliably find `modern.sh.`
If you have `modern.sh` in your path, you're good to start using it with just:
```shell
source "$(which modern.sh)"
```
If you set it up as a library in a relative path and aren't sure where it might end up, then you'll need to do something like this (where `libpath` is the relative path from your script):
```shell
source "$(dirname "${BASH_SOURCE[0]}")/libpath/modern.sh"
```
Pretty much every function is documented in `doc/help.ansi`, just display it in your terminal or an ansi-capable editor to read more:
```shell
cat doc/help.ansi
```
Plans
=====
I've used a lot of these functions for many years, copied from project to project, but this version was extracted from my `blacklight` programming language [build scripts](https://github.com/acook/blacklight/blob/redlight/build/lib/_shared.).
While I mainly use `fish` interactively, `modern.sh` currently heavily depends on bash-isms due to it being readily available on all platforms I have come into contact as well as having a decent set of primitives to build on. While that has been a safe assumption for the last couple of decades, it is no longer the case. Making it `zsh` compatible will not be a stretch. Eventually `modern.sh` will grow a deeper compatibility layer to allow it to run on `dash` and `busybox` or similar.