A robust set of POSIX-compliant scripts for shell environments.
The goal is to provide a simple API that is compatible with Bourne-like shells on *nix systems.
All functions have been tested in bash
, dash
, fish
, ksh
, and zsh
.
- confirm
- export-file
- join-file
- log-level
- pipe-file
- print-text
- read-file
- require
- substring
- start-daemon
- stop-daemon
- strict-mode
- terminate
- watch-daemon
- write-file
-
Install this project via
npm
.npm i shell-api --save
Method A
#!/usr/bin/env sh
SHELL_API_PATH="/path/to/shell-api/shell"
export SHELL_API_PATH
# Load all the scripts at once
. "${SHELL_API_PATH}"/shell-api
export-file ./.env
require <SCRIPT>
...
Method B
#!/usr/bin/env sh
SHELL_API_PATH="/path/to/shell-api/shell"
export SHELL_API_PATH
# Selectively load scripts
. "${SHELL_API_PATH}"/strict-mode
. "${SHELL_API_PATH}"/export-file
. "${SHELL_API_PATH}"/require
export-file ./.env
require <SCRIPT>
...