Skip to content

abbotto/shell-api

Repository files navigation

shell-api

Build Status NPM version GitHub version

Overview

A robust set of POSIX-compliant scripts for shell environments.

Shell support

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.

The API


Getting started

Install

  • Install this project via npm.

    npm i shell-api --save
    

Usage

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>

...