Skip to content

abbotto/shell-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
J. Abbott
Oct 17, 2019
772c810 · Oct 17, 2019

History

50 Commits
Oct 17, 2019
Oct 17, 2019
Oct 17, 2019
Oct 17, 2019
Aug 2, 2018
Aug 2, 2018
Oct 17, 2019
Oct 17, 2019
Aug 2, 2018
Oct 17, 2019
Jul 22, 2019
Oct 17, 2019
Aug 2, 2018
Oct 17, 2019
Oct 17, 2019

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>

...